exchange web service error - the remote server returned an error 405 method not allowed

。_饼干妹妹 提交于 2019-12-10 03:59:45

问题


I'm trying to send a mail via the exchange web service. I looked into the msdn and find some help. Every time I try to run this code i'm getting the above error :( I try read almost everywhere...

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);

service.Credentials = new WebCredentials("My user name", "my pass");

System.Net.ServicePointManager.ServerCertificateValidationCallback =
        ((sender, certificate, chain, sslPolicyErrors) => true);

service.Url = new Uri("my web service url.WSDL");
    EmailMessage appointment = new EmailMessage(service);

appointment.Subject = "Test by me";
appointment.Body = "DateTime.Now";
appointment.ToRecipients.Add("xxxxxxx@gmail.com");

appointment.SendAnd

SaveCopy();

回答1:


When setting the url to the service, you should in fact use the asmx, and not the wsdl link.

service.Url = new Uri("https://server/EWS/Exchange.asmx");

That should make it work.



来源:https://stackoverflow.com/questions/10164651/exchange-web-service-error-the-remote-server-returned-an-error-405-method-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!