如何使用c#从当前outlook电子邮件中获取嵌入图像?

如何使用c#从当前outlook电子邮件中获取嵌入图像?,c#,outlook-addin,outlook-2010,C#,Outlook Addin,Outlook 2010,我正在visual studio 2010中使用c#.net开发outlook 2010插件 我想将当前电子邮件(未附加)中的嵌入图像嵌入到我的表单区域 如何从outlook电子邮件中获取嵌入图像 我试图从谷歌上找到答案,但所有这些都展示了如何在电子邮件中嵌入图像。 但我想从outlook电子邮件中获取嵌入图像 有人能帮我吗?您应该能够使用:Microsoft.Office.Interop.Outlook。下面是一个巨大的项目列表。你可能不得不把它当作一种依恋;将其保存到另一个文件夹。然后递归地

我正在visual studio 2010中使用c#.net开发outlook 2010插件

我想将当前电子邮件(未附加)中的嵌入图像嵌入到我的表单区域

如何从outlook电子邮件中获取嵌入图像

我试图从谷歌上找到答案,但所有这些都展示了如何在电子邮件中嵌入图像。 但我想从outlook电子邮件中获取嵌入图像


有人能帮我吗?

您应该能够使用:
Microsoft.Office.Interop.Outlook
。下面是一个巨大的项目列表。你可能不得不把它当作一种依恋;将其保存到另一个文件夹。然后递归地从那里提取数据

private void ThisApplication_Startup(object sender, System.EventArgs e)
{
    this.NewMail += new Microsoft.Office.Interop.Outlook
        .ApplicationEvents_11_NewMailEventHandler(ThisApplication_NewMail);
}

private void ThisApplication_NewMail()
{
    Outlook.MAPIFolder inBox = this.ActiveExplorer()
        .Session.GetDefaultFolder(Outlook
        .OlDefaultFolders.olFolderInbox);
    Outlook.Items inBoxItems = inBox.Items;
    Outlook.MailItem newEmail = null;
    inBoxItems = inBoxItems.Restrict("[Unread] = true");
    try
    {
        foreach (object collectionItem in inBoxItems)
        {
            newEmail = collectionItem as Outlook.MailItem;
            if (newEmail != null)
            {
                if (newEmail.Attachments.Count > 0)
                {
                    for (int i = 1; i <= newEmail
                       .Attachments.Count; i++)
                    {
                        newEmail.Attachments[i].SaveAsFile
                            (@"C:\TestFileSave\" +
                            newEmail.Attachments[i].FileName);
                    }
                }
            }
        }
    }
    catch (Exception ex)
    {
        string errorInfo = (string)ex.Message
            .Substring(0, 11);
        if (errorInfo == "Cannot save")
        {
            MessageBox.Show(@"Create Folder C:\TestFileSave");
        }
    }
}
private void this应用程序\u启动(对象发送方,System.EventArgs e)
{
this.NewMail+=新的Microsoft.Office.Interop.Outlook
.ApplicationEvents\u 11\u NewMailEventHandler(此应用程序\u NewMail);
}
私有作废此应用程序\u NewMail()
{
Outlook.MAPIFolder收件箱=this.ActiveExplorer()
.Session.GetDefaultFolder(Outlook
.OlDefaultFolders.olFolderInbox);
Outlook.Items inBoxItems=收件箱.Items;
Outlook.MailItem newEmail=null;
inBoxItems=inBoxItems.Restrict(“[Unread]=true”);
尝试
{
foreach(inBoxItems中的对象集合项)
{
newEmail=collectionItem作为Outlook.MailItem;
if(newEmail!=null)
{
如果(newEmail.Attachments.Count>0)
{

对于(inti=1;我非常感谢Greg。您的代码解决了我的问题。非常感谢。