我有这段代码:
public List<Attachment> GetAttachments() {
string hostname = "pop.gmail.com";
int port = 995;
bool useSSL = true;
string attachmentType = "application/pdf";
string email = "myemail@gmail.com";
string emailFrom = "someone@gmail.com";
string password = TxtBoxPassword.Text;
if (!string.IsNullOrWhiteSpace(password))
{
Pop3Client client = new Pop3Client();
client.Connect(hostname, port, useSSL);
client.Authenticate(email, password, AuthenticationMethod.UsernameAndPassword);
List<Attachment> listAttachments = new List<Attachment>();
int count = client.GetMessageCount();
for (int i = count; i >= 1; i--)
{
Message message = client.GetMessage(i);
if (message.Headers.From.MailAddress.Address == emailFrom)
{
List<MessagePart> attachments = message.FindAllAttachments();
foreach (MessagePart attachment in attachments)
{
if (attachment.ContentType.MediaType == attachmentType)
listAttachments.Add(new Attachment(attachment));
}
}
}
}
}
阅读电子邮件帐户中的所有电子邮件。
它访问电子邮件帐户并从已发送/收件箱文件夹中获取265封电子邮件。
目前我在该帐户中有超过一千封电子邮件,因此我希望在电子邮件数量上看到这个数字。
代码/ Gmail帐户设置中缺少什么阻止我收到所有电子邮件?
由于
答案 0 :(得分:0)
嗯,当它获得POP3功能时,gmail有些怪癖。请参阅What non-standard behaviour features does Gmail exhibit, when it is programmatically used as a POP3 server?上的答案。我不认为你可以改变任何可以解决问题的设置。