自动发现无法处理给定的电子邮件地址。仅允许邮箱和联系人

时间:2016-08-08 10:39:40

标签: email outlook ms-office exchangewebservices exchange-server-2010

使用ExchangeService发送电子邮件时抛出异常,因为消息为:"自动发现服务返回错误。"和"自动发现无法处理给定的电子邮件地址。 只允许邮箱和联系人"。

public void SendEmail(string to, string cc, string subject, string body,  string emailType)
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
            service.Credentials = new WebCredentials("test@outlook.com", "test");        
            service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;            
            service.AutodiscoverUrl("test@outlook.com", RedirectionUrlValidationCallback);

            EmailMessage email = new EmailMessage(service);
            email.ToRecipients.Add(to);
            email.CcRecipients.Add(cc);
            email.Subject = subject;
            email.Body = new MessageBody(body);
            email.Send();
        }
        private static bool RedirectionUrlValidationCallback(string redirectionUrl)
        {
            bool result = false;
            Uri redirectionUri = new Uri(redirectionUrl);
            if (redirectionUri.Scheme == "https")
            {
                result = true;
            }
            return true;
        }

以上代码与" ... @ microsoft.com"但没有与" ... outlook.com"

任何人都可以帮助解决问题。enter image description here

0 个答案:

没有答案