I have written a program in C# which connects to a POP Server and retrieves raw email message strings from the server using POP3 command RETR.
Since the email message being retrieved by the program is in plain text format with all the headers and message body with in the same, its too difficult to extract each header and mail body from the raw string.
Could anybody tell me a solution by which I can parse the entire raw text to a System.Net.Mail.MailMessage object?
Following is a sample email raw string:
+OK 1281 octets
Return-Path: <sample@test.in>
Delivered-To: samplenet-sample:in-sample2@test.in
X-Envelope-To: sample2@test.in
Received: (qmail 53856 invoked from network); 22 Sep 2012 06:11:46 -0000
Received: from mailwash18.pair.com (66.39.2.18)
MIME-Version: 1.0
From: "Deepu"
<sample@test.in>
To: sample2@test.in
Date: 22 Sep 2012 11:41:39 +0530
Subject: TEST Subject
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Message-Id: <20120922061146.2975C11554D@mailwash18.pair.com>
TEST Body
.
After a bit research I could find the OpenPop.Net open source library which has almost all the short hand methods to communicate with a POP3 server.
It is highly useful since it will wrap up the raw email message to a strongly typed
Messageobject and the different parts of an email message including any of its attachments can also be accessed separately. It is really awesome!Here is the link:
http://hpop.sourceforge.net/