我有这样的代码:
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封电子邮件。
目前我在帐户中有超过1000封电子邮件,所以我希望在电子邮件计数中看到这个数字。
代码/Gmail帐户设置中缺少什么使我无法获取所有电子邮件?
谢谢
发布于 2015-07-11 15:01:39
当涉及到POP3的功能时,gmail有一些奇怪的地方。请看我在What non-standard behaviour features does Gmail exhibit, when it is programmatically used as a POP3 server?上的回答。我不认为你可以改变任何设置来解决你的问题。
https://stackoverflow.com/questions/31308255
复制相似问题