read email using exchange web services

后端 未结 6 599
灰色年华
灰色年华 2021-01-05 01:43

This is my scenario: I have to read email from exchange 2010 sp2 accounts. I have to use Exchange Web Services, POP3 and IMAP are blocked. I have to test my app in an enviro

6条回答
  •  梦毁少年i
    2021-01-05 02:11

    This works like a charm to me:

       var exchange = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
       var username = Settings.EmailUserName;
       var password = Settings.EmailPassword;
       var domain = Settings.EmailDomain;
       var email = Settings.Email;
       exchange.Credentials = new WebCredentials(email, password);
       exchange.AutodiscoverUrl(email, RedirectionCallback);
    

    and the RedirectionCallback is:

     static bool RedirectionCallback(string url)
            {
                // Return true if the URL is an HTTPS URL.
                return url.ToLower().StartsWith("https://");
            }
    

    heres is the link: https://msdn.microsoft.com/en-us/library/office/dd635285(v=exchg.80).aspx

    Regards!

提交回复
热议问题