Microsoft's Exchange Mail Service is different from the General mail server, he can not simply use components such as smtpclient to achieve mail messaging functions.
So how do you send mail through the Exchange service?
Microsoft's Exchange services have a WebService interface, and the easiest way to send mail is through the webservice they provide.
Verify that the webservice of the Exchange service is healthy: https://xx.xxxxx.com/ews/exchange.asmx, it is normal to open. You may need to log in.
However, this webservice is different from ordinary webservice, and cannot be simply added to the Web invocation.
First we need to download a Microsoft.Exchange.WebServices.dll, and then refer to our project inside, http://www.microsoft.com/en-us/download/details.aspx id=28952, is an MSI, after the installation of the DLL, and then you can start.
Here is an example of sending a message:
Using microsoft.exchange.webservices;using Microsoft.Exchange.WebServices.Data; private void SendEmail () { Exchangeservice service = new Exchangeservice (); Get authentication, be able to try your mailbox name, domain user ID, etc. //User: Login username, email login ID or domain login ID //password: You understand //domain: Domains, not domain names, Domain users, you have to fill in this, select the service. Credentials = new NetworkCredential ("User", "password", "domain"); Service. TraceEnabled = true; Service. Autodiscoverurl ("[email protected]"); This is the sender's email address, complete ([email protected]). Emailmessage message = new Emailmessage (service); Message. Subject = "subject of email"; Message. Body = "content of email"; Message. Torecipients.add ("Recipient's email address"); Message. Save (); Message. SendAndSaveCopy ();//Send }
C # Send mail through Exchange Server