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

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

问题描述

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

I need the ability to monitor for and read e-mail from a particular mailbox on a MS Exchange Server (internal to my company). I also need to be able to read the sender's e-mail 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)?

推荐答案

一团糟.MAPI 或 CDO 通过 .NET 互操作 DLL 是 微软官方不支持--它看起来工作正常,但由于内存不同而存在内存泄漏问题楷模.您可以使用 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天全站免登陆