如何检测在 Outlook 加载项中撰写的电子邮件的格式?

How to detect the format of the email being composed in an Outlook Add-in?

我看到当消息正文为纯文本时,如果将 options.coercionType 设置为 Office.CoercionType.Html 调用 Office.context.mailbox.item.body.setSelectedDataAsync() 会失败。

我想知道在调用setSelectedDataAsync之前是否有任何方法可以检查消息正文的格式?

您需要在 Outlook API 文档中使用 <a href="https://dev.office.com/reference/add-ins/outlook/1.5/Body?product=outlook&version=v1.5" rel="nofollow noreferrer">getTypeAsync</a> method of the body object. Even more, this is suggested way to insert any data into the mail item's body. Before inserting, you should always first verify the supported item format by calling getTypeAsync. Please read more on the topic how to Insert data in the body when composing an appointment or message in Outlook