IMAP component for .NET

Recently Mail.dll email component got new IMAP client. IMAP, short for Internet Message Access Protocol, is one of the two most prevalent Internet standard protocols for e-mail retrieval, the other being the Post Office Protocol (POP3).

The simplest code to access IMAP server looks as follows:

using(Imap imap = new Imap())
{
	imap.Connect"imap.server.com");
	imap.Login("user", "password");

	imap.SelectInbox();
	List<long> uidList = imap.SearchFlag(Flag.Unseen);
	foreach (long uid in uidList)
	{
		IMail mail = new MailBuilder()
			.CreateFromEml(imap.GetMessageByUID( uid ));

		Console.WriteLine(mail.Subject);
	}
	imap.Close(true);
}

and for those who like VB.NET more:

Using imap As New Imap()
	imap.Connect("imap.server.com")
	imap.Login("user", "password")

	imap.SelectInbox()
	Dim uidList As List(Of Long) = imap.SearchFlag(Flag.Unseen)
	For Each uid As Long In uidList
		Dim mail As IMail = New MailBuilder()_
			.CreateFromEml(imap.GetMessageByUID(uid))

		Console.WriteLine(mail.Subject)
	Next
	imap.Close(True)
End Using

You can’t get much simpler than that!

All necessary IMAP features are there:

  • Create, Delete and Rename folders
  • Download and upload emails
  • Move email messages between folders
  • Flagging messages
  • Powerful search, with great syntax (I’ll blog about that later, as I really enjoyed writing this feature)
  • And of course fully tested Mail.dll parser

It works perfectly with GMail as well.

If you like it just give it a try and download it at: Mail.dll .NET email component

Tags: ,

Leave a Reply