Gmail API使用自动生成的HTML替换了正文/纯文本替换的正文部分 [英] Gmail API replaces text/plain alternative body part with automatically generated one from HTML

查看:80
本文介绍了Gmail API使用自动生成的HTML替换了正文/纯文本替换的正文部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有替代 text/plain 版本的Gmail API从Android设备发送电子邮件.该电子邮件的结构如下:

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

text/plain 部分外,其他所有内容都可以正常运行,而该部分已被从 text/html 部分提取的经过净化的版本取代.

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

如果我尝试发送到与发件人相同的地址(从电子邮件X到电子邮件X),则将同时保留原始文本/纯文本和文本/html版本.如果我发送给其他人(从电子邮件X到电子邮件Y)并且电子邮件通过Google的服务器,则会替换 text/plain 版本,而将 text/html 版本替换为消毒.

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.

我真的不介意对 text/html 版本进行清理,但是我需要保留原始的 text/plain 版本.

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

有人知道我如何阻止Gmail执行此操作吗?

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

推荐答案

尝试遵循答案

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

用户应根据用户的环境和偏好选择最佳"类型,或为用户提供可用的替代方案.通常,选择最佳类型意味着只显示可以显示的LAST部分.

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.

它基于答案中链接的文档.

这篇关于Gmail API使用自动生成的HTML替换了正文/纯文本替换的正文部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆