C # Send mail through Exchange Server

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.