I need to be able to make a program that looks through a mailbox of bounced messages, where the messages come back with the initial message in a .msg attachment, and open the .msg attachment for processing in ASP.NET 2.0. Is there any sort of code that might help in this? I've been looking at http://stackoverflow.com/questions/44383/reading-email-using-pop3-in-c as a starting point, but can't figure out how best to open the attachment from there, or if there's some easier way I'm missing.
views:
104answers:
3From your post, it appears that you are better off getting a third party component that had already implemented (POP or IMAP) the protocol. I just googled and got one and I bet there are a bunch out there. http://www.jscape.com/articles/retrieving_email_pop3_csharp.html
Parsing bounce messages in general is a huge task, because their formats vary greatly between different mail transport agents. So unless you are on a closed network, or you only care for bounces reported directly from your own transport agent, then you are in for a big job, and you certainly cannot count on the original messages being attached in full to the bounce answers.
If it is possible for you to regenerate the outgoing mails from a few key parameters, then you might want to consider using a VERP addressing scheme instead. Your parsing job would then be reduced to recognizing and deciphering the recipient addresses of the bounce messages, instead of their full content.
I ended up going with a solution involving reading in the messages using Microsoft.Office.Interop.Outlook ( http://support.microsoft.com/?kbid=310244 ), saving the attached .msg to the drive, then finally reading in that message using an open-source third party solution ( http://www.codeproject.com/KB/office/reading_an_outlook_msg.aspx ). It's probably not the most efficient solution overall, but it handles the specific case we needed to support.