首页 > 解决方案 > 使用 openpop 连接到 Outlook 时提供的主机名应该是什么

问题描述

我正在使用 openPop 库连接到电子邮件并使用我的 c# 代码获取。

我可以通过提供服务器详细信息作为主机名:“pop.gmail.com”,端口:995,SSL:true insdide client.connect() 方法从 gmail 帐户获取邮件。然后调用 client.Authenticate("recent: " + 用户名、密码、AuthenticationMethod.UsernameAndPassword)。但是当我尝试访问 Outlook 邮件时,更改凭据后无法连接。以下是我分别用于连接 gmail 和 Outlook 的代码。

//gmail连接

        var client = new Pop3Client();

        using (Pop3Client client2 = new Pop3Client())
        {
            // Connect to the server
            client.Connect("pop.gmail.com", 995, true);
            client.Authenticate("recent:" + userName, password, 
            AuthenticationMethod.UsernameAndPassword);
        }

//前景连接

        var client = new Pop3Client();

        using (Pop3Client client2 = new Pop3Client())
        {
            // Connect to the server
            client.Connect("outlook.office365.com", 995, true);

            client.Authenticate("recent:" + userName, password, AuthenticationMethod.UsernameAndPassword);

}

我在使用 Outlook 凭据时遇到错误,如下所示: PopServerException:服务器未响应 + 响应。响应是:“-ERR 登录失败:未知用户名或密码错误。” 我还在 POP 和 IMAP 下启用了内部 Outlook 设置,在允许设备和应用程序使用 POP 下设置为是。

标签: c#openpop

解决方案


推荐阅读