c# - 自动发现本地异常 : The Autodiscover service couldn't be located

标签 c# .net email exchange-server exchangewebservices

我想使用.NET 3.5访问Exchange服务器。这是我的代码:

class Program
{
    static void Main(string[] args)
    {
        try
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
            service.Credentials = new WebCredentials("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96f3fbf7fffac9e2f3e5e2d6eeeeeeb8f5f9fb" rel="noreferrer noopener nofollow">[email protected]</a>", "abcd");

            service.AutodiscoverUrl("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8ddd5d9d1d4e7ccddcbccf8c0c0c096dbd7d5" rel="noreferrer noopener nofollow">[email protected]</a>");

            EmailMessage message = new EmailMessage(service);
            message.Subject = "Interesting";
            message.Body = "The proposition has been considered.";
            message.ToRecipients.Add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e7868584a79f9f9fc984888a" rel="noreferrer noopener nofollow">[email protected]</a>");
            message.SendAndSaveCopy();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

我指的是this article编写代码:

但是我收到了这个异常:

AutodiscoverLocalException: The Autodiscover service couldn't be located.

有人可以帮忙吗?

最佳答案

我遇到了这个问题,这是由于用户帐户被锁定所致。

关于c# - 自动发现本地异常 : The Autodiscover service couldn't be located,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11929607/

相关文章:

c# - 发送 "on behalf of"电子邮件

html - 创建简单的 html 电子邮件需要哪些 html 标记?

c# - 从 C# 问题执行命令

c# - C# 如何知道某个文件将触发哪个进程

.net - NHibernate/FluentNHibernate和SQLite在内存中进行映射测试

c# - 如何在 C# 代码中正确使用 PowerShell 模块

c# - 如何获取 Yammer 中特定组的待定用户列表

c# - 使用 MySQL 后端开发 C# 项目的最佳方法是什么?

.net - 跨项目的部分类

个人电子邮件的 PHPMailer 设置发送空到 : fields