将图像作为多部分/相关 MIME 对象添加到 Outlook with Office Js Addin

Add images as multipart/related MIME object to Outlook with Office Js Addin

本文关键字:Outlook 添加 with Office Addin Js 对象 MIME 图像 多部 相关      更新时间:2023-09-26

我正在使用addFileAttachmentAsync将图像作为附件添加到Outlook 2016中的电子邮件中。有没有办法指定附件选项?我看到有一个附件详细信息类型,我可以以某种方式使用它来指定其他选项吗?我的目标是使用多部分/相关的 MIME 对象嵌入图像。

内联图像目前在平台中没有很好的支持。我们正在努力改进这一点。同时,您可以包含从 Web 加载图像<img>标记,也可以使用此代码。在 OWA 中,发件人将看到附件很好地出现在附件中,而在 Outlook 中,图像根本不会为发件人呈现。但在这两种情况下,收件人都会看到正确的内联图像。

Office.context.mailbox.item.addFileAttachmentAsync(
"http://smartbuildings.unh.edu/wp-content/uploads/2015/06/Winter-Tiger-Wild-Cat-Images-1024x576.jpg",
"Winter-Tiger-Wild-Cat-Images-1024x576.jpg",
{asyncContext: null},
function (asyncResult) 
 {
  if (asyncResult.status == "failed") {
    //showMessage("Action failed with error: " + asyncResult.error.message);
  }
  else
{ 
Office.context.mailbox.item.body.setSelectedDataAsync(
                        "<img src='cid:Winter-Tiger-Wild-Cat-Images-1024x576.jpg'>",
                        { coercionType: Office.CoercionType.Html, 
                        asyncContext: { var3: 1, var4: 2 } },
                        function (asyncResult) {
                            if (asyncResult.status == 
                                Office.AsyncResultStatus.Failed){
                                showMessage(asyncResult.error.message);
                            }
                            else {
                                // Successfully set data in item body.
                                // Do whatever appropriate for your scenario,
                                // using the arguments var3 and var4 as applicable.
                            }
                        });
}
});