How to parse the MailMessage object from raw email string

Posted by Xmindz on Stack Overflow See other posts from Stack Overflow or by Xmindz
Published on 2012-09-22T09:34:52Z Indexed on 2012/09/22 9:37 UTC
Read the original article Hit count: 308

Filed under:
|
|
|

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: <[email protected]>
Delivered-To: samplenet-sample:[email protected]
X-Envelope-To: [email protected]
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"
 <[email protected]>
To: [email protected]
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: <[email protected]>


TEST Body

.

© Stack Overflow or respective owner

Related posts about c#

Related posts about email