如何在C#中使用Outlook MAPI来打开.eml文件? [英] How to open .eml files using Outlook MAPI in C#?

查看:506
本文介绍了如何在C#中使用Outlook MAPI来打开.eml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序读取.msg文件并提取正文和附件。但是,当我尝试加载.eml文件的应用程序崩溃。我加载像这样的文件:

I have a C# application that reads .msg files and extracts the body and the attachments. But when I try to load a .eml file the application crashes. I am loading the files like this:

MailItem mailItem = (MailItem)outlookApp.CreateItemFromTemplate(msgFileName);
mailItem.SaveAs(fullFilename, OlSaveAsType.olHTML); // save body in html format
for(int i = 0; i < mailItem.Attachments.Count; i++)
    mailItem.Attachments[i].SaveAsFile(filename); // save attachments

这正常工作与.msg文件,但它并不适用于.eml文件的工作。我不明白为什么.eml文件不工作,因为我可以在Outlook 2010中打开.eml文件。

This works fine with .msg files, but it doesn't work for .eml files. I don't understand why .eml files don't work, because I can open .eml files in Outlook 2010.

我如何可以加载的.eml使用Outlook 主Interop大会?

How can I load .eml files using the Outlook Primary Interop Assembly?

推荐答案

试试这个示例code的容易从.eml文件

Try this sample code Easily Retrieve Email Information from .EML Files

这篇关于如何在C#中使用Outlook MAPI来打开.eml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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