Gmail API replaces text/plain alternative body part with automatically generated one from HTML

a 夏天 提交于 2019-12-13 06:44:41

问题


I'm sending emails from Android devices using the Gmail API with an alternative text/plain version. The email is structured as follows:

multipart/mixed
  multipart/alternative
    text/plain
    text/html
  attachment

Everything works great, except for the text/plain part, which is being replaced by a sanitized version extracted from the text/html part.

If I try sending to the same address as the sender (from email X to email X), both the original text/plain and text/html versions are maintained. If I send to someone else (from email X to email Y) and the email goes through Google's servers, the text/plain version is replaced and the text/html version is sanitized.

In simpler words: if I check the content in "Sent Mail", the original plain/text version is there. It is only replaced in the email that reaches the recipient.

I don't really mind the text/html version getting sanitized, but I need to keep the original text/plain version.

Does anyone have an idea of how I can keep Gmail from doing this?


回答1:


Try to follow the answer here. Try to switch the order of the message, putting the HTML part first before the text/plain part.

The user should either choose the "best" type based on the user's environment and preferences, or offer the user the available alternatives. In general, choosing the best type means displaying only the LAST part that can be displayed.

It is based on the document that was link in the answer.



来源:https://stackoverflow.com/questions/36431526/gmail-api-replaces-text-plain-alternative-body-part-with-automatically-generated

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