开发者

How to send receive mail from MS Exchange

How can I , from a custom c# application, create and send/receive mails from MS Exchange?

I am assuming this is not directly possible with the standard framework mail classes.

If I could say that this needs to work with MS Exchange 2003 and 2007 what are my options?

Ideally I dont want to buy a third party component so if this is possi开发者_如何学编程ble with c# then what are the steps for creating a library that can send a new mail or receive a mail into a custom application.

The C# app will be local, as in the same network as the Exchange server.


Have you tried using the built-in .Net mail assemblies?

If you create an SmtpClient client = new SmtpClient("my-email-server"), does smtp.Send not work?

----- with code

If the machine has a mail account setup then no, it should use the ones from the system so long as you set DefaultNetworkCredentials:

SmtpClient smtp = new SmtpClient("mailserver"); 
smtp.Credentials = CredentialCache.DefaultNetworkCredentials; 

You can create some though and use those instead:

SmtpClient client = new SmtpClient("myserver"); 
client.Credentials = new NetworkCredential("username", "password", "domain");


Have you put the following code in your web.config file?

<system.net><mailSettings><smtp><network 
  host="host.name.com" port="port number"
  userName="username" password="password"/></smtp></mailSettings></system.net>


There's a number of routes to look at: MAPI, CDO, 3rd party libraries etc.

What version of Exchange is it you're working with as I think 2007 has some web services that you can use that OWA plugs in to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜