我正在尝试通过交换网络服务发送邮件.我查看了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");
这应该使它工作.