我有这个代码:
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 帐户设置中缺少什么?
谢谢