Dear rickwats,
Please check it out. Basically, if you want to access any info about an email message, you can get a MailMessage instance firstly. Pop3Client and ImapClient all support to fetch message from server and cast into a MailMessage instance.
1) for Pop3
Pop3Client client = new Pop3Client("localhost", "user", "12345678");
Pop3MessageInfoCollection infos = null;
client.Connect(true); //connect to server, and auto login to it
infos = client.ListMessages(); //list the messages in the server
if(infos != null)
{
for (int i = 0; i < infos.Count; i++)
{
MailMessage msg = client.FetchMessage(infos[ i ].SequenceNumber);//fetch message to local
foreach (Attachment att in msg.Attachments) //enumerate attachments in the message
{
Console.WriteLine(att.Name + " " + att.MediaType + " " + att.ContentType);
}
}
}
2) for Imap
ImapClient client2 = new ImapClient("localhost", "testuser", "psw");
client2.Connect(true); //connect to server, and auto login to it
client2.SelectFolder("Inbox"); //select the folder
ImapMessageInfoCollection infos2 = null;
infos2 = client2.ListMessages(); // list the messages
if(infos2 != null)
{
for (int i = 0; i < infos2.Count; i++)
{
MailMessage msg = client2.FetchMessage(infos2[ i ].SequenceNumber); //fetch message to local
foreach (Attachment att in msg.Attachments) //enumerate attachements in the message
{
Console.WriteLine(att.Name + " " + att.MediaType + " " + att.ContentType);
}
}
}