通过EWS API连接到Office 365 [英] Connection to Office 365 by EWS API
本文介绍了通过EWS API连接到Office 365的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用我的控制台应用程序来处理邮箱项目EWS API和我的连接脚本看起来像
I am using EWS API in my console application to process mailbox items and my connection script looks like
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("emailService@domain.com");
但我发现我的电子邮件帐户被转移到Office 365云。我应该如何更改身份验证?
But i found that my email account was moved to Office 365 cloud. How should i change the authentication ?
我发现EWS服务网址
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
但我不知道如何使用它。
but i dont know how to use it.
感谢您
推荐答案
您可以使用下面的代码连接到EWS上的Office 365:
You can use the code below to connect to the EWS on office 365:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("emailService@domain.com", "password");
service.AutodiscoverUrl("emailService@domain.com", RedirectionUrlValidationCallback);
您需要定义一个回调函数的AutodiscoveryUrl功能,如:
You need define one callback function for the AutodiscoveryUrl function, like this:
private static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
这篇关于通过EWS API连接到Office 365的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文