Mail.dll - .NET email component (IMAP, POP3)
IMAP component and POP3 component that allows sending, receiving and processing email messages in .NET applications.
Written entirely in managed code. Works with .NET 2.0, 3.0, 3.5 and 4.0 including Mono.
Features
What folks are saying about Mail.dll
- "Best email component, best price, best support..."
- "I’ve installed 4 or so other components from other vendors, played with each of them to see how easy they are to work with, and yours was up and running quicker, easier, and better than all the others."
- "Thank you very much. I like your .NET library - it's wonderful"
- "I found your .NET email component 'Mail.dll' extremely useful"
- "Mail.dll is an absolutely fantastic library. I would recommend it to anyone who needs to send or receive e-mail from .NET applications"
Quick start samples
-
Receive emails from IMAP server using C#
using(Imap imap = new Imap())
{
imap.Connect("imap.server.com"); // or ConnectSSL for SSL
imap.UseBestLogin("user", "password");
imap.SelectInbox();
List<long> uids = imap.SearchFlag(Flag.Unseen);
foreach (long uid in uids)
{
IMail email = new MailBuilder()
.CreateFromEml(imap.GetMessageByUID(uid));
Console.WriteLine(email.Subject);
}
imap.Close();
}
-
Receive emails from POP3 server using C#
using(Pop3 pop3 = new Pop3())
{
pop3.Connect("pop3.server.com"); // or ConnectSSL for SSL
pop3.UseBestLogin("user", "password");
List<string> uids = pop3.GetAll();
foreach (string uid in uids)
{
IMail email = new MailBuilder()
.CreateFromEml(pop3.GetMessageByUID(uid));
Console.WriteLine(email.Subject);
}
pop3.Close();
}
-
Send email using SMTP server using C#
IMail email = Mail
.Html(@"Html with an image: <img src=""cid:lena"" />")
.AddVisual(@"c:\lena.jpeg").SetContentId("lena")
.AddAttachment(@"c:\tmp.doc").SetFileName("document.doc")
.To("to@example.com")
.From("from@example.com")
.Subject("Subject")
.Create();
using(Smtp smtp = new Smtp())
{
smtp.Connect("smtp.server.com"); // or ConnectSSL for SSL
smtp.UseBestLogin("user", "password");
smtp.SendMessage(email);
smtp.Close();
}
-
Receive emails from IMAP server using VB.NET
Using imap As New Imap
imap.Connect("imap.server.com") ' or ConnectSSL for SSL
imap.UseBestLogin("user", "password")
imap.SelectInbox()
Dim uidList As List(Of Long) = imap.SearchFlag(Flag.Unseen)
For Each uid As Long In uidList
Dim email As IMail = New MailBuilder() _
.CreateFromEml(imap.GetMessageByUID(uid))
Console.WriteLine(email.Subject)
Next
imap.Close()
End Using
-
Receive emails from POP3 server using VB.NET
Using pop3 As New Pop3
pop3.Connect("pop3.server.com") ' or ConnectSSL for SSL
pop3.UseBestLogin("user", "password")
For Each uid As String In pop3.GetAll()
Dim email As IMail = New MailBuilder() _
.CreateFromEml(pop3.GetMessageByUID(uid))
Console.WriteLine(email.Subject)
Next
pop3.Close()
End Using
-
Send email using SMTP server using VB.NET
Dim email As IMail = Mail _
.Html("Html with an image: <img src=""cid:lena"" />") _
.AddVisual("C:\lena.jpeg").SetContentId("lena") _
.AddAttachment("C:\tmp.doc").SetFileName("document.doc") _
.To("to@example.com") _
.From("from@example.com") _
.Subject("Subject") _
.Create()
Using smtp As Smtp = New Smtp
smtp.Connect("smtp.server.com") ' or ConnectSSL for SSL
smtp.UseBestLogin("user", "password")
smtp.SendMessage(email)
smtp.Close()
End Using
Our customers
Next steps