Coolcoder
Coolcoder

Reputation: 4036

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 possible 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.

Upvotes: 2

Views: 3372

Answers (3)

shree mahamuni
shree mahamuni

Reputation: 11

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>

Upvotes: 1

Antony Koch
Antony Koch

Reputation: 2053

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");

Upvotes: 2

Chris W
Chris W

Reputation: 3324

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.

Upvotes: 0

Related Questions