我正在尝试使用Microsoft.Office.Interop.Outlook
发送带有图片附件的电子邮件。
这是我的代码:
Application OutlookApplication = new Application();
MailItem email = (MailItem)OutlookApplication.CreateItem(OlItemType.olMailItem);
email.Subject = Title;
email.To = ToUserName + "@gmail.com";
email.Importance = StringPriortyToOLImportance(SelectedPriority);
Attachment attachment = email.Attachments.Add(
@imagePath
, OlAttachmentType.olEmbeddeditem
, null
, "Screenshot"
);
string imageCid = Path.GetFileName(imagePath);
attachment.PropertyAccessor.SetProperty(
"http://schemas.microsoft.com/mapi/proptag/0x3712001E"
, imageCid
);
imagesHTML = "<img src=\"cid:" + imageCid + "\">";
email.HTMLBody = "<body>" + Description + "<br><br>" + imagesHTML + "</body>";
email.Send();
代码确实发送电子邮件,我唯一遇到的问题是图像显示如下: 而且我似乎找不到解决方案。
非常感谢您的帮助。