Set content-type of mail message for ical attachment to “text/calendar; method=REQUEST”

跟風遠走 提交于 2019-12-02 10:00:34

问题


I am trying to send an iCalendar formatted ics file from App Engine using the App Engine mail API. This works great in GMail. However, Outlook doesn't recognise the file, and I believe the issue is that the content-type is set to "text/calendar" and not "text/calendar; method=REQUEST".

I have tried sending mail with telnet with and without "method=REQUEST" to find that Outlook only actions the ics file if this is included. I have checked the headers sent from App Engine, to find that they do not include method=REQUEST and that is why I believe this is the problem.

I have also seen other people report this issue here and here. There is a java solution to the first link, but having now gone through the App Engine mail api with a fine toothcomb I have so far been unable to set the content-type using Python.

I have tried overriding the EXTENSION_MIME_MAP dict:

mail.EXTENSION_MIME_MAP['ics'] = 'text/calendar; charset=utf-8; method=REQUEST;'

and setting the header myself:

message.headers = {'content-type': 'text/calendar; charset=utf-8; method=REQUEST;'}

Both were a long shot, and unsurprisingly, neither work.

So how can this be done?

来源:https://stackoverflow.com/questions/23656802/set-content-type-of-mail-message-for-ical-attachment-to-text-calendar-method-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!