EWS托管API-使用内嵌图像保存草稿 [英] EWS Managed API - Save Draft with inline Images

查看:93
本文介绍了EWS托管API-使用内嵌图像保存草稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to create emails for my users using EWS Managed API 1.1, and need to use email templates our designers have created. I was able to successfully attach image (say header.png) and add an image tag like this (using cid: before the image name) in the html body.

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

这在我使用msg.SendAndSaveCopy()方法时有效.在已发送邮件"文件夹和收件人收件箱中,它都可以完美呈现.但是,当我尝试使用msg.Save()方法只是将其另存为草稿文件夹中时,它不起作用.它以简单的附件形式显示图像,而主体不以内联方式显示图像.即使我按下了send in Outlook,它们也无法正确渲染.我想知道是否需要做一些特殊的事情才能使这些图像在Outlook Drafts文件夹中正确呈现.

This works when I use msg.SendAndSaveCopy() method. It renders perfectly fine in both Sent Mail folder and the recipients inbox. However it is not working when I try to use msg.Save() method just to save it as Draft in Drafts folder. It shows images as plain attachments and the body doesn't show images inline. They don't render properly even if I hit send in outlook. I am wondering if I need to do anything special to have these images rendered correctly in outlook Drafts folder.

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

Any pointers/ help will be greatly appreciated.

推荐答案

Microsoft今天提供了一种解决方法来解决此问题.发布解决方案以使社区受益

Microsoft provided a workaround today to address this issue. Posting the solution for the benefit of the community

      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();

这篇关于EWS托管API-使用内嵌图像保存草稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆