【问题标题】:IMAP using c# - AE.Net.MailIMAP 使用 c# - AE.Net.Mail
【发布时间】:2013-04-03 15:00:03
【问题描述】:

我一直在尝试使用以下链接中提供的解决方案:
using c# .net librarires to check for IMAP messages from gmail servers

但我一直报错:
连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应

这里有什么我想念的吗。我的代码:

    public List<MailMessage> ReadMail()
    {
        List<MailMessage> msgs;
        using (var ic = new AE.Net.Mail.ImapClient("imap.gmail.com", "username@gmail.com", "pass-to-gmail", ImapClient.AuthMethods.Login, 993, true))
        {
            ic.SelectMailbox("INBOX");
            msgs = new List<MailMessage>(ic.GetMessageCount());
            msgs = ic.GetMessages(0, 100, false, true).ToList();

            ic.Disconnect();
        }
        return msgs;
    }

【问题讨论】:

  • 有完整源代码的最终解决方案吗?

标签: c# .net email imap


【解决方案1】:

使用这段代码连接到 gmail。

ImapX.ImapClient client = null;
client = new ImapX.ImapClient("imap.gmail.com", 993, true);

if (!client.Connection())
{
    MessageBox.Show("Couldn't connect to gmail. Check your internet connection and try again");
    client = null;
    return false;
 }

 if (!client.LogIn(email, password))
 {
     MessageBox.Show("Email And/Or password incorrect");
     client = null;
     return false;
 }

【讨论】:

  • 嘿,谢谢。原来我的网络阻止了呼叫请求。当我使用不同的网络使用相同的代码时,它可以工作。
  • 嗨,阿米特,我尝试运行您的相同代码。它失败了:(是因为有防火墙保护代码不访问邮件吗?请提出建议。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-02
  • 1970-01-01
  • 1970-01-01
  • 2013-02-25
  • 2012-08-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多