通过编码将邮件正文复制到新邮件 [英] Copying mail body to new mail by coding

查看:100
本文介绍了通过编码将邮件正文复制到新邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Outlook 2013中,我希望以编程方式在新邮件中添加邮件正文内容。

以下是我的相同代码:

In Outlook 2013 I want content of mail body in a new mail programmatically.
Below is my code for same:

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
    Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
    Outlook.Application oApp = new Outlook.Application();
    Outlook.Explorer oExplorer = oApp.ActiveExplorer();
    Outlook.Selection oSelection = oExplorer.Selection;

    foreach (object item in oSelection)
    {
        Outlook.MailItem mi = (Outlook.MailItem)item;
        mailItem.HTMLBody = mi.HTMLBody;
    }
}



一切正常,但原始邮件中的图像不会显示,而是显示类似cid:image002.png的内容。



不确定是什么原因请帮助。



我也想把它交给客户,所以我无法在本地保存邮件内容。


Everything works fine, but the image present in original mail is not displayed, instead it shows something like cid:image002.png.

Not sure what is the reason please help.

Also i want to give it to client, so i can't save mail content local.

推荐答案

您还需要复制附件。根据您提供的代码的上下文,这应该有效:



You need to copy the attachments over as well. Based on the context of the code that you gave, this should work:

...
foreach (object item in oSelection)
    {
        Outlook.MailItem mi = (Outlook.MailItem)item;
        mailItem.HTMLBody = mi.HTMLBody;
        if(mi.Attachments != null && mi.Attachmets.Count > 0)
        {
           foreach(var attach in mi.Attachments)
           {
               mailItem.Attachments.Add(attach);
           }
        }
    }





在Outlook中,附件用作图像数据源嵌入式图像。



In Outlook the attachments are used as the image data source for "embedded" images.


这篇关于通过编码将邮件正文复制到新邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆