简体   繁体   中英

Using EWS API I get “Exchange Server doesn't support the requested version”

I have been trying to use the simple example given on this MS page . It seems quite straight forward but I get the error message "Exchange Server doesn't support the requested version"

private void SendEmail()  
    {  
        ExchangeService service = new ExchangeService();  
        service.AutodiscoverUrl(UserPrincipal.Current.EmailAddress);  

        EmailMessage message = new EmailMessage(service);  
        message.Subject = "ima subject";  
        message.Body = "I am text to read in body";  
        message.ToRecipients.Add("colleague@yourdomain.com");  
        message.Save();  

        message.SendAndSaveCopy();  

        System.Windows.MessageBox.Show("Message sent!");  
    } 

Well, we are currently in the middle of a change from Exchange 2007 to a newer version(2013 maybe). So this might be the problem, otherwise I assume it would actually "autodiscover".

I simply changed the first line to this:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM