问题
I'm looking at the API docs, and it looks like you can specify only one Body
in a Message
.
Sending a message:
https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#SendMessages
The Message
type:
https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar#MessageResource
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.
回答1:
Can Office 365 REST API send an email with both plain text and HTML body?
No, you will use REST point to set one type of the body or another.
Is it possible to do something like a multi-part message with plain text and 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.
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.
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".
来源:https://stackoverflow.com/questions/43723930/can-office-365-rest-api-send-an-email-with-both-plain-text-and-html-body