【发布时间】:2017-10-23 21:15:41
【问题描述】:
我正在将 C# 控制台应用程序作为 Azure Webjob 上传。我得到的错误是:
未处理的异常: Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: 找不到自动发现服务。
在 Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List1 redirectionEmailAddresses, Int32& currentHop)
在 Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String 电子邮件地址)
在 Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(字符串 emailAddress, List`1 requestedSettings)
在 Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(字符串 userSmtpAddress, UserSettingName[] userSettingNames)
在 Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(字符串 emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
在 Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(字符串 电子邮件地址,自动发现重定向UrlValidationCallback validateRedirectionUrlCallback)
这是我的代码:
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;
}
static void Main(string[] args)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("email@mySite.com", "myPassword", "mysite.com");
service.AutodiscoverUrl("email@mySite.com", RedirectionUrlValidationCallback);
// More irrelevant code here
}
上面的代码取自这个问题,作为已接受的答案:Connection to Office 365 by EWS API
将此代码作为控制台应用程序在我的机器上运行,运行良好。但是这个错误作为一个网络作业,有人可以帮忙吗?
【问题讨论】:
-
我在 Azure 上使用 EWS 时遇到了问题,在寻找答案后最终决定在本地服务器上运行控制台应用程序,并使用任务计划程序使其按设定的计划运行
-
@hellyale 希望我能诊断出问题,但不幸的是,我无法舒适地求助于本地服务器来执行该过程。 :(
标签: c# web-services azure exchange-server exchangewebservices