私はこのコードを持っています:
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 通のメールを取得します。
現在、アカウントには 1,000 通以上のメールがあるので、この数のメール数が表示されることを期待しています。
すべてのメールを受信できない原因となっているコード/Gmail アカウント設定の欠落は何ですか?
ありがとう