Exchangeservice (EWS) can locate the server in two ways

Source: Internet
Author: User

When you use C # To receive emails from an Exchange mailbox, you must specify the user name, password, and domain name. The other information is the email address, as shown in the following example:

// Connect to the server exchangeservice service = new exchangeservice (exchangeversion. exchange2007_sp1); service. credentials = new networkcredential ("User Name", "password", "Domain Name"); service. autodiscoverurl ("email address ");

Another way is to directly specify the WSDL address of the Exchange Server,CodeAs follows:

// Connect to the server exchangeservice service = new exchangeservice (exchangeversion. exchange2007_sp1); service. credentials = new networkcredential ("User Name", "password", "Domain Name"); service. url = new uri (http: // server/EWS/exchange. asmx );

The difference between the two methods:

The first method is to directly write the email address, which will automatically locate your server address, so that your server address will change and the code will not be modified, but the disadvantage is that the address location error is often reported or cannot be found (I don't know why)

The second method has the advantage of faster positioning and accuracy. Basically, no error is reported. The disadvantage is that if the server address changes, you still need to modify the code.

Personal conclusion: the second method is better. To avoid errors, we recommend that you read the address from the configuration file for convenient management.

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.