Csharp/C#教程:VSTO Outlook嵌入图像MailItem分享


VSTO Outlook嵌入图像MailItem

我需要在用户签名之后将图像作为电子邮件的一部分嵌入,而不是在电子邮件的末尾,因为如果我发送大型电子邮件的回复,嵌入式图像将位于底部电子邮件链

我正在使用VSTO,VS2008 Fwk3.5和Outlook 2007

这是我的代码:

public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend); } private void Application_ItemSend(object Item, ref bool Cancel) { if (Item is Outlook.MailItem) { Outlook.MailItem mailMessage = (Outlook.MailItem)Item; //do something to add the image after the signature } } 

最后我解决了这个问题:

上述就是C#学习教程:VSTO Outlook嵌入图像MailItem分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 private void SendFormatted(Outlook.MailItem mail) { if (!string.IsNullOrEmpty(mail.HTMLBody) && mail.HTMLBody.ToLower().Contains("")) { //Get Image + Link string imagePath = @"D:\MediaImagenes100MSDCFDSC00632.JPG"; object linkAddress = "https://www.pentavida.cl"; //CONTENT-ID const string SchemaPR_ATTACH_CONTENT_ID = @"https://schemas.microsoft.com/mapi/proptag/0x3712001E"; string contentID = Guid.NewGuid().ToString(); //Attach image mail.Attachments.Add(imagePath, Outlook.OlAttachmentType.olByValue, mail.Body.Length, Type.Missing); mail.Attachments[mail.Attachments.Count].PropertyAccessor.SetProperties(SchemaPR_ATTACH_CONTENT_ID, contentID); //Create and add banner string banner = string.Format(@"
Csharp/C#教程:VSTO Outlook嵌入图像MailItem分享", linkAddress, contentID); mail.HTMLBody = mail.HTMLBody.Replace("", banner); mail.Save(); } }

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1034059.html

(0)
上一篇 2022年1月18日
下一篇 2022年1月18日

精彩推荐