Office 365 REST API可以发送包含纯文本和HTML正文的电子邮件吗? [英] Can Office 365 REST API send an email with both plain text and HTML body?

查看:178
本文介绍了Office 365 REST API可以发送包含纯文本和HTML正文的电子邮件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看API文档,看来您只能在Message中指定一个Body.

I'm looking at the API docs, and it looks like you can specify only one Body in a Message.

发送消息:

https://msdn.microsoft .com/en-us/office/office365/api/mail-rest-operations#SendMessages

Message类型:

https ://msdn.microsoft.com/zh-cn/office/office365/api/complex-types-for-mail-contacts-calendar#MessageResource

是否可以执行包含纯文本和HTML的多部分消息?

Is it possible to do something like a multi-part message with plain text and HTML?

最终,我希望将此消息与日历会议邀请一起发送,但这是另一个主题.

Ultimately I'm looking to send this message with an attached calendar meeting invitation, but that's another topic.

推荐答案

Office 365 REST API可以发送包含纯文本和HTML正文的电子邮件吗?

Can Office 365 REST API send an email with both plain text and HTML body?

否,您将使用REST点设置主体的一种或另一种类型.

No, you will use REST point to set one type of the body or another.

是否可以执行包含纯文本和HTML的多部分消息?

Is it possible to do something like a multi-part message with plain text and HTML?

当邮件在发送时转换为MIME时,将由Exchange环境为您完成. Exchange将生成MIME的多部分/替代"部分,并为您使用REST调用设置的内容设置适当的纯文本和HTML.例如,如果您通过休息请求设置"HTML"正文,则传出的MIME将具有您设置的HTML部分,以及备用的"plaintext"部分,该部分将由Exchange MIME转换器生成,以剥离版本的形式显示为您的裸文本HTML;反之亦然.

This will be done for you by Exchange environment when message will be converted to MIME on send. Exchange will generate "multipart/alternative" parts of the MIME and set appropriate plain text and HTML for the content you set with your REST call. For example if you set "HTML" body via rest request, the outgoing MIME will have HTML part, as you set it, and alternative "plaintext" part, which will be generated by Exchange MIME converter as strip off version to bare text of your HTML; and vise versa.

请注意,我们不讨论与邮件附件有关的多部分/混合"部分.这只是关于邮件正文的替代部分.

Please note we are not discussing "multipart/mixed" parts which related to attachments of the message. This is only about alternative parts for the body of the message.

最后,查看Microsoft Outlook应用程序.作为Exchange环境的另一个客户端,这无非是.您可以将消息撰写为纯文本,也可以选择将其撰写为RTF/HTML,但不要两者都写.替换部分将由 Exchange MIME转换器作为消息的一部分-> MIME转换和MIME将具有同一正文的替代部分.

Finally, look at the Microsoft Outlook application. This is nothing else as yet another client for Exchange environment. You may compose message as plain text or choose to compose it as RTF/HTML, but never both. The alternative part will be generated by Exchange MIME converter as the part of Message -> MIME conversion and MIME will have alternative parts of the same body.

最后,我很想知道我是否回答您的问题,因为通过评论看来您知道什么是"multipart/alternative"以及它与"multipart/mixed"有何不同.

At the end I am mot sure if I answered on your question, because by the comments it looks like you know what is "multipart/alternative" and how it's different from "multipart/mixed".

这篇关于Office 365 REST API可以发送包含纯文本和HTML正文的电子邮件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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