【问题标题】:Outlook getAsync Email Content img tag not working properlyOutlook getAsync 电子邮件内容 img 标记无法正常工作
【发布时间】:2022-08-03 17:59:19
【问题描述】:

我已经获得了电子邮件的 html 内容,并且工作正常。但我有问题,我的一封电子邮件的正文中嵌入了屏幕截图。现在我可以得到图像列表(见下图)

但是前景给我的img标签是这样的;

<img class=\"x_w-1378 x_h-886\" size=\"349452\" data-outlook-trace=\"F:1|T:1\" src=\"cid:9ea35d14-aa1e-47d6-9c5b-b31ced143981\" style=\"max-width:100%\">

<img width=\"643\" height=\"359\" id=\"x_Picture_x0020_1\" src=\"cid:image001.png@01D8A327.B5A0B590\" style=\"width:6.6979in; height:3.7395in\">

现在我怎么知道这张图片是用于这个附件的,反之亦然。

这是我获取电子邮件正文的代码

Office.context.mailbox.item.body.getAsync(\"html\", {coercionType: Office.CoercionType.Html}, 
function (result) { 
  var body = result.value.trim();
  console.log(var);
});

希望任何人都可以回答我或给我一些提示

谢谢

    标签: outlook office-js outlook-addin office-addins outlook-web-addins


    【解决方案1】:

    图像的来源以cid: 前缀声明,方式如下:

    src="cid:9ea35d14-aa1e-47d6-9c5b-b31ced143981"
    

    相应的附件将具有相同的名称或来自 PR_ATTACH_CONTENT_ID 属性的值(DASL 名称是“urn:schemas:mailheader:content-id”)。您可以使用 EWS 来提取此位。

    isInline 属性获取一个值,该值指示附件是否应显示在项目的正文中。有关 Web 加载项中附件的可用属性,请参阅 Office.AttachmentDetails interface

    【讨论】:

    • 是的,我知道 isInline 属性。我对此没有问题。我只想知道这张图片是针对html内容上的这个img标签的,如果outlook给我这种img标签<img class="x_w-1378 x_h-886" size="349452" data-outlook-trace="F:1|T:1" src="cid:9ea35d14-aa1e-47d6-9c5b-b31ced143981" style="max-width:100%"><img width="643" height="359" id="x_Picture_x0020_1" src="cid:image001.png@01D8A327.B5A0B590" style="width:6.6979in; height:3.7395in">我无法使用Office.context将它与附件进行比较.mailbox.item.attachments
    • 我们可以使用 cid:: 前缀来比较附件。图像的来源在 cid::prefix 中声明,我们可以将其与从附件 API docs.microsoft.com/en-us/javascript/api/outlook/… 获得的附件名称进行比较
    猜你喜欢
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 2011-08-03
    相关资源
    最近更新 更多