For an app I needed a componenet to get mail from a pop mail server. After some browsing I took a shot at devMail.net. It looks pretty comprehensible, quite powerfull and has very fair licensing. To try the componenet I built a small winform application with the same functionality as my provider's webmail. I need that to skim my spam mailbox. The main problem with the provider's (xs4all) webmail is that it is completely brain-dead. It's a collection of php pages which forget all selections on every roundtrip. Very annoying to work with.
My winform / devmail.net mail client was so easy to build and works so well that I just have to share this with you. It does a couple of things
- Get a list of email headers and load these in a checkedlistbox
- Forward the selected messages to another email address
- Delete all selected messages from the mailbox
All devmail stuff is in one assembly. Add it to your references, to your using clauses and you're off.
Setting up an in- and outbox:
POP3 Inbox = new POP3();
SMTP Outbox = new SMTP();
private void Form1_Load(object sender, System.EventArgs e)
{
Inbox.Host = "pop.xs4all.nl";
Inbox.Username = "pobboxname";
Inbox.Password = "mypwd";
Outbox.Host = "smtp.xs4all.nl";
Outbox.Username = Inbox.Username;
Outbox.Password = Inbox.Password;
Outbox.AuthenticationMode = SMTPAuthenticationMode.Login;
}
Getting the headers is a snap
private void buttonGetHeaders_Click(object sender, System.EventArgs e)
{
if (Inbox.Connect())
{
checkedListBox1.Items.Clear();
foreach(MailMessage msg in Inbox)
{
checkedListBox1.Items.Add(string.Format("From {0} : {1}", msg.From, msg.Subject));
}
}
}
To forward selected messages
private void buttonForward_Click(object sender, System.EventArgs e)
{
foreach(int i in checkedListBox1.CheckedIndices)
{
MailMessage msg = Inbox[i];
msg.To.Clear();
msg.To.Add(textBoxFwd.Text);
if (! Outbox.SendMessage(msg))
MessageBox.Show(Outbox.LastError);
}
}
And to delete selected messages
private void buttonDelete_Click(object sender, System.EventArgs e)
{
foreach(int i in checkedListBox1.CheckedIndices)
Inbox.DeleteMessage(i , false);
}
That's all. Fill in the configuration to your own likes. Included are loads of samples, including a windows service which polls a mailbox at regular intervals. All in simple to-the-point coding. Lovely.
I do like the product. But.. does anybody have real-life experience with the product ? How does it behave in the wild ?
blog on,
Peter