1

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?

luz
  • 73
  • 1
  • 6

1 Answers1

0

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.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Thanks @KENdi. I've tried it but now I'm always getting the text/plain version in all email clients. I still need the HTML version to be given priority. However, if the email client doesn't support HTML, I need the original text/plain version to be presented, and not some auto-generated version from the Gmail API. I know it's sent, but somewhere along the way it gets replaced by what seems to be an automatically generated version extracted from the text/html version. – luz Apr 06 '16 at 15:52