Exchange web service error - remote server returned error 405 method not allowed

I am trying to send mail through a web sharing service. I looked in msdn and found some help. Every time I try to run this code, I get the above error :( I try to 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();
+5
source share
1 answer

When setting up the service url, you should use asmx and not the wsdl link.

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

That should make it work.

+15
source

All Articles