学习EWS Managed API,碰到 The Autodiscover service could not be located.的错误,不知道是什么原因。代码如下(从msdn上copy的):
try
{
// Connect to Exchange Web Services as user1 at contoso.com.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials("user1", "password", "contoso.com");
service.AutodiscoverUrl("[email protected]"); // Create the e-mail message, set its properties, and send it to [email protected], saving a copy to the Sent Items folder.
EmailMessage message = new EmailMessage(service);
message.Subject = "Interesting";
message.Body = "The proposition has been considered.";
message.ToRecipients.Add("[email protected]");
message.SendAndSaveCopy(); // Write confirmation message to console window.
Console.WriteLine("Message sent!");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.ReadLine();
}
请高手赐教,万分感谢
try
{
// Connect to Exchange Web Services as user1 at contoso.com.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials("user1", "password", "contoso.com");
service.AutodiscoverUrl("[email protected]"); // Create the e-mail message, set its properties, and send it to [email protected], saving a copy to the Sent Items folder.
EmailMessage message = new EmailMessage(service);
message.Subject = "Interesting";
message.Body = "The proposition has been considered.";
message.ToRecipients.Add("[email protected]");
message.SendAndSaveCopy(); // Write confirmation message to console window.
Console.WriteLine("Message sent!");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.ReadLine();
}
请高手赐教,万分感谢
我也碰到了一模一样的问题,跪求帮助~