VSTO Outlook 嵌入图像邮件项目 [英] VSTO Outlook Embed Image MailItem
本文介绍了VSTO Outlook 嵌入图像邮件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将图像作为电子邮件的一部分嵌入,在用户签名之后,而不是在电子邮件的末尾,因为如果我要发送一封大型电子邮件的回复,嵌入的图像将在电子邮件链的底部
I need to embed an image as a part of the email, after the User Signature, not at the end of the email, becasue if i'm sending a reply of a large email, the embedded Image it's going to be at the bottom of the emails chain
- 如何将图像嵌入到电子邮件内容中(不是外部图像的链接)?
- 如何在用户签名后添加此图片?
- How do I embed an image as part of the email content (Not a link to an outside image)?
- How do I add this image after the user Signature?
我正在使用 VSTO、VS2008 Fwk3.5 和 Outlook 2007
I'm work with VSTO, VS2008 Fwk3.5 and 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
}
}
推荐答案
最后我解决了这个问题:
Finally i Solved the problem with this:
private void SendFormatted(Outlook.MailItem mail)
{
if (!string.IsNullOrEmpty(mail.HTMLBody) && mail.HTMLBody.ToLower().Contains("</body>"))
{
//Get Image + Link
string imagePath = @"D:\MediaImagenes100MSDCFDSC00632.JPG";
object linkAddress = "http://www.pentavida.cl";
//CONTENT-ID
const string SchemaPR_ATTACH_CONTENT_ID = @"http://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(@"<br/><a href=""{0}"" ><img src=""cid:{1}"" ></a></body>", linkAddress, contentID);
mail.HTMLBody = mail.HTMLBody.Replace("</body>", banner);
mail.Save();
}
}
这篇关于VSTO Outlook 嵌入图像邮件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文