由网友(苦闷丢进酒杯)分享简介:我需要嵌入图像作为电子邮件的一部分,在用户签名后,未在邮件的末尾,becasue如果我发送了大量的电子邮件回复,嵌入式图像这将是在在电子邮件链的下端如何嵌入图像作为电子邮件内容的一部分(不是链接到外部图像)?在用户签名后如何添加这一形象? 我和VSTO,VS2008 Fwk3.5和Outlook 2007年工作下面是我...![如何在Outlook的正文中插入图片](https://p.xsw88.cn/allimgs/daicuo/20230907/4142.png)
我需要嵌入图像作为电子邮件的一部分,在用户签名后,未在邮件的末尾,becasue如果我发送了大量的电子邮件回复,嵌入式图像这将是在在电子邮件链的下端
如何嵌入图像作为电子邮件内容的一部分(不是链接到外部图像)? 在用户签名后如何添加这一形象?我和VSTO,VS2008 Fwk3.5和Outlook 2007年工作
下面是我的code:
公共部分类的ThisAddIn
{
私人无效ThisAddIn_Startup(对象发件人,发送System.EventArgs)
{
this.Application.ItemSend + =新Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(实现Application_ItemSend);
}
私人无效实现Application_ItemSend(对象项目,楼盘布尔取消)
{
如果(项目是Outlook.MailItem)
{
Outlook.MailItem mailMessage =(Outlook.MailItem)项目;
//做一些事情来签名后添加图像
}
}
解决方案
最后我解决了问题,这样的:
私人无效SendFormatted(Outlook.MailItem邮件)
{
如果(string.IsNullOrEmpty(mail.HTMLBody)及!&安培; mail.HTMLBody.ToLower()包含(&所述; /体>中))
{
//获取图片+链接
字符串的ImagePath = @D:媒体 Imagenes 100MSDCF DSC00632.JPG;
反对linkAddress上=http://www.pentavida.cl;
//内容id
常量字符串SchemaPR_ATTACH_CONTENT_ID = @http://schemas.microsoft.com/mapi/proptag/0x3712001E;
。字符串内容ID = Guid.NewGuid()的ToString();
//附加图片
mail.Attachments.Add(的ImagePath,Outlook.OlAttachmentType.olByValue,mail.Body.Length,Type.Missing);
mail.Attachments [mail.Attachments.Count] .PropertyAccessor.SetProperties(SchemaPR_ATTACH_CONTENT_ID,内容ID);
//创建并添加旗帜
串横幅=的String.Format(@&所述峰; br />&所述; A HREF ={0},>&所述; IMG SRC =CID:{1},>&所述; / a取代; < /身体gt;中,linkAddress上,内容ID);
mail.HTMLBody = mail.HTMLBody.Replace(< /身体gt;中,旗);
mail.Save();
}
}
![如何在Outlook的正文中插入图片](https://p.xsw88.cn/allimgs/daicuo/20230907/4142.png)
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?I'm work with VSTO, VS2008 Fwk3.5 and Outlook 2007
Here is my code:
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();
}
}
相关推荐
最新文章