You can use Mail.dll https://www.limilabs.com/mail to connect to your IMAP server and download email messages. Mail.dll supports SSL and TLS protocols.
Messages in IMAP/POP3 and SMTP use eml plain text MIME format,
and this can be written to disk:
using(Imap imap = new Imap())
{
imap.ConnectSSL("imap.example.com");
imap.UseBestLogin("user", "password");
imap.SelectInbox();
List<long> uids = imap.Search(Flag.Unseen);
foreach (long uid in uids)
{
var eml = imap.GetMessageByUID(uid);
// Write to disk:
File.WriteAllByte($"c:\\email{uid}.eml", eml);
// Parse eml MIME data:
IMail email = new MailBuilder()
.CreateFromEml(eml);
Console.WriteLine(email.Subject);
}
}
Msg is proprietary Microsoft format, and Mail.dll can only read those.
This article shows how to download unseen messages from IMAP:
https://www.limilabs.com/blog/receive-unseen-emails-using-imap
You can find many samples here:
https://www.limilabs.com/mail/samples
You can find pricing info here:
https://www.limilabs.com/mail/purchase
Most common Q and A are here:
https://www.limilabs.com/mail/help