【发布时间】:2018-04-12 15:04:43
【问题描述】:
我正在尝试使用 MailSystem.Net 从我的 gmail 帐户中检索邮件,但出现上述错误。我似乎没有在 googl 上找到与此类错误相关的任何链接。这是我的代码
public class MailRepository
{
private Imap4Client client;
public MailRepository(string mailServer, int port, bool ssl, string login, string password)
{
if (ssl)
Client.ConnectSsl(mailServer, port);
else
Client.Connect(mailServer, port);
}
public IEnumerable<Message> GetAllMails(string mailBox)
{
return GetMails(mailBox, "ALL").Cast<Message>();
}
public IEnumerable<Message> GetUnreadMails(string mailBox)
{
return GetMails(mailBox, "UNSEEN").Cast<Message>();
}
protected Imap4Client Client
{
get { return client ?? (client = new Imap4Client()); }
}
private MessageCollection GetMails(string mailBox, string searchPhrase)
{
Mailbox mails = Client.SelectMailbox(mailBox);
MessageCollection messages = mails.SearchParse(searchPhrase);
return messages;
}
}
这是我得到的错误:命令“list”inbox“*”失败:171031010631135 BAD Unknown command b7mb174701481wmf
private void ReadImap()
{
var mailRespository = new MailUtil.MailRepository("imap.gmail.com", 993, true, "myGmailAccount", "Mypassword");
var emailList = mailRespository.GetAllMails("inbox");
foreach(Message email in emailList)
{
//DoSomething
if(email.Attachments.Count > 0)
{
//DoSomething
}
}
}
我做错了什么??我只是出于演示目的复制我在此处在线阅读的内容。
【问题讨论】:
-
请提供完整的错误和回溯。如果相关,在您的问题中
-
Command "list "inbox" "*"" failed : 171031010631135 BAD Unknown command b7mb174701481wmf 是我遇到的错误之一。我将其编写为服务,并将错误记录到文件夹中。我可以在我创建的日志文件夹中找到一系列命令“列表”收件箱“错误
-
您似乎从未登录过。您传递了您的用户名和密码,但从不使用它。
-
再次,在您的问题中提供您的全部错误。按编辑链接更改您的问题并提供所有相关信息。
-
刚刚做了
标签: c# imap gmail-imap