I need to get all emails in mailbox. And i need to read attachment's bodies to get info. But i have encoding issue and can't solve this problem.
Code sample:
using (var client = new ImapClient())
{
client.ServerCertificateValidationCallback = (s, c, h, b) => true;
client.Connect("imap.secureserver.net", 143, SecureSocketOptions.Auto); // godaddy
client.Authenticate("username", "password");
client.Inbox.Open(FolderAccess.ReadOnly);
IList<UniqueId> uids = client.Inbox.Search(SearchQuery.All);
foreach (UniqueId uid in uids)
{
MimeMessage message = client.Inbox.GetMessage(uid);
foreach (MimeEntity attachment in message.Attachments)
{
var fileName = "test" + Tools.GenerateRandomString(5);
if ((attachment is MessagePart))
{
var attachmentBody = ((MessagePart)attachment).Message.ToStringNullSafe();
}
}
}
}
Attachment Header:
Content-Type: text/plain;charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Encoding Issue In Attachment Body
Subject: Bili=C5=9Fim A.=C5=9E.