c# – 交换Web服务错误 – 远程服务器返回错误405方法不允许

前端之家收集整理的这篇文章主要介绍了c# – 交换Web服务错误 – 远程服务器返回错误405方法不允许前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试通过交换网络服务发送邮件.我查看了msdn并找到了一些帮助.
每次我尝试运行此代码我都会收到上述错误:(
我几乎到处尝试阅读……
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();

解决方法

将url设置为服务时,实际上应该使用asmx,而不是wsdl链接.
service.Url = new Uri("https://server/EWS/Exchange.asmx");

这应该使它工作.

猜你在找的C#相关文章