首页 文章

电子邮件中的图像在Hotmail或Gmail中显示为附件

提问于
浏览
0

我正在使用Microsoft.Office.Interop.Outlook.MailItem发送电子邮件,这是一个html电子邮件,其中包含一些图像,我发送图像作为这样的附件

mailItem.Attachments.Add(path + "Header.png", (int)OlAttachmentType.olByValue, 1, "Header");

然后设置身体

string body=”<img src="cid:{0}" width="627" height="125" alt="Header">”
mailItem.BodyFormat = OlBodyFormat.olFormatHTML;                
mailItem.HTMLBody = string.Format(body, "Header.png") ;

在MS Outlook中一切正常,但是图像在Hotmail(outlook.com)和Gmail中显示为附件,但在MS Outlook中,图像显示在正文中,应该显示在哪里

我搜索并找到了类似的解决方案,如果我为我的图像设置cid,例如域名,例如Header.png @ somedomain.com然后它会工作,但它不起作用,当我为附件设置这种类型的名称时出现恶意附件的警告

请建议

1 回答

  • 1

    您正在为标头指定cid属性,但您从未设置Content-ID MIME标头 . 要在邮件转换为MIME时进行设置,您需要使用Attachment.PropertyAccessor.SetProperty设置PR_ATTACH_CONTENT_ID MAPI属性(DASL名称“http://schemas.microsoft.com/mapi/proptag/0x3712001F”) .

相关问题