2

我正在尝试使用 EWS Managed API 1.1 为我的用户创建电子邮件,并且需要使用我们的设计师创建的电子邮件模板。我能够成功地附加图像(比如 header.png )并在 html 正文中添加这样的图像标记(在图像名称之前使用 cid: )。

<img width=683 height=27 src="cid:header.png" alt="Header">

这在我使用msg.SendAndSaveCopy()方法时有效。它在已发送邮件文件夹和收件人收件箱中都呈现得非常好。但是,当我尝试使用msg.Save()仅将其保存为草稿文件夹中的草稿的方法时,它不起作用。它将图像显示为普通附件,正文不显示内联图像。即使我在 Outlook 中点击发送,它们也无法正确渲染。我想知道是否需要做任何特别的事情才能使这些图像在 Outlook 草稿文件夹中正确呈现。

任何指针/帮助将不胜感激。

4

1 回答 1

2

Microsoft 今天提供了一种解决方法来解决此问题。发布解决方案以造福社区

      string html = @"<html>
                 <head>
                 </head>
                 <body>
                    <img width=200 height=100  id=""1"" src=""cid:Desert.jpg"">
                 </body>
                 </html>";

        newMessage.Body = new MessageBody(BodyType.HTML, html);
        string file = @"D:\Tools\Desert.jpg";
        newMessage.Attachments.AddFileAttachment("Desert.jpg", file);
        newMessage.Attachments[0].IsInline = true;

        //this is required to fix the issue - Add content id programatically
        newMessage.Attachments[0].ContentId = "<Desert.jpg>";

        newMessage.Save();
于 2012-06-11T18:21:56.663 回答