在C#中阅读MS Exchange电子邮件 [英] Read MS Exchange email in C#

查看:109
本文介绍了在C#中阅读MS Exchange电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够监视和阅读MS Exchange Server(我公司内部)的特定邮箱的电子邮件。我还需要能够阅读发件人的电子邮件地址,主题,邮件正文,并下载附件(如果有的话)。

I need the ability to monitor for and read email from a particular mailbox on a MS Exchange Server (internal to my company). I also need to be able to read the sender's email address, subject, message body and download an attachment if any.

使用C#或Vb.net)?

What is the best way to do this using C# (or Vb.net)?

推荐答案

这是一个混乱。通过.NET互操作DLL的MAPI或CDO是正式不受Microsoft支持 - 这似乎工作正常,但由于内存不同而导致内存泄漏有问题楷模。您可以使用CDOEX,但它只适用于Exchange服务器本身,而不是远程;无用。你可以互操作Outlook,但现在你只是依靠Outlook;矫枉过正。最后,您可以使用 Exchange 2003的WebDAV支持,但是WebDAV很复杂, .NET对它的内置支持很差,并且(增加侮辱伤害)Exchange 2007 几乎完全下降支持WebDAV。

It's a mess. MAPI or CDO via a .NET interop DLL is officially unsupported by Microsoft--it will appear to work fine, but there are problems with memory leaks due to their differing memory models. You could use CDOEX, but that only works on the Exchange server itself, not remotely; useless. You could interop with Outlook, but now you've just made a dependency on Outlook; overkill. Finally, you could use Exchange 2003's WebDAV support, but WebDAV is complicated, .NET has poor built-in support for it, and (to add insult to injury) Exchange 2007 nearly completely drops WebDAV support.

什么是一个人要做?最后我使用 AfterLogic的IMAP组件通过IMAP与我的Exchange 2003服务器通信,这最终工作得很好。 (我通常会寻找免费或开源的图书馆,但是我发现所有想要的.NET - 尤其是在2003年的IMAP实施中的一些奇怪之处 - 而且这个数据便宜得多,并且在第一个尝试,我知道那里还有其他人。)

What's a guy to do? I ended up using AfterLogic's IMAP component to communicate with my Exchange 2003 server via IMAP, and this ended up working very well. (I normally seek out free or open-source libraries, but I found all of the .NET ones wanting--especially when it comes to some of the quirks of 2003's IMAP implementation--and this one was cheap enough and worked on the first try. I know there are others out there.)

然而,如果您的组织在Exchange 2007上,那么你会幸运的。 Exchange 2007附带了一个基于SOAP的Web服务界面,最终提供了一个统一的,与语言无关的与Exchange服务器交互的方式。如果你能使2007+成为一个要求,这绝对是要走的路。 (对于我来说,可悲的是,我的公司有一个但是2003没有破坏的政策。)

If your organization is on Exchange 2007, however, you're in luck. Exchange 2007 comes with a SOAP-based Web service interface that finally provides a unified, language-independent way of interacting with the Exchange server. If you can make 2007+ a requirement, this is definitely the way to go. (Sadly for me, my company has a "but 2003 isn't broken" policy.)

如果你需要桥接Exchange 2003和2007,IMAP或POP3是绝对是要走的路。

If you need to bridge both Exchange 2003 and 2007, IMAP or POP3 is definitely the way to go.

这篇关于在C#中阅读MS Exchange电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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