By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,165 Members | 1,916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,165 IT Pros & Developers. It's quick & easy.

How to parse multi-part messages in MIME format?

P: n/a
I would like to parse an email, which I receive from a pop3 account.
While the subject and the sender's email address are probably easy to
determine, the body seems to be more difficult because of multi-part
messages in MIME format.
I am interested only in the plain text.
Do you know an easy way to retrieve plain text of the body from an email
message?
Maybe a class, which can be constructed using the whole message string as a
parameter and which provides properties similar to the MailMessage class?

Here you find examples what I have for MIME and plain text:

"+OK 2144 octets
Return-Path: <xxx>
Received: from natnoddy.rzone.de (natnoddy.rzone.de [81.169.145.166])
by mx9.evanzo-server.de (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) with ESMTP id
i8IJXcH21749
for <xxx>; Sat, 18 Sep 2004 21:33:40 +0200
Received: from gauss (pD9EA804A.dip0.t-ipconnect.de [217.234.128.74])
by post.webmailer.de (8.12.10/8.12.10) with ESMTP id i8IJXIGx012016
for <xxx>; Sat, 18 Sep 2004 21:33:21 +0200 (MEST)
Message-ID: <xxx>
From: <xxx>
To: <xxx>
Subject: MySubject
Date: Sat, 18 Sep 2004 21:31:32 +0200
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_003F_01C49DC6.DE16FB30"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
X-Spam-Status: No, hits=2.6 required=10.0
tests=HTML_50_60,HTML_MESSAGE,RCVD_IN_NJABL,RCVD_I N_ORBS,
RCVD_IN_OSIRUSOFT_COM,X_NJABL_DIALUP
version=2.52
X-Spam-Level: **
X-Spam-Checker-Version: SpamAssassin 2.52 (1.174.2.8-2003-03-24-exp)
X-UIDL: a80fd03ed87acc5f2ff1c427fcd9d8f4

This is a multi-part message in MIME format.

------=_NextPart_000_003F_01C49DC6.DE16FB30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MyBody
------=_NextPart_000_003F_01C49DC6.DE16FB30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp;</DIV>MyBody</BODY></HTML>

------=_NextPart_000_003F_01C49DC6.DE16FB30--
"

"+OK 1322 octets
Return-Path: <xxx>
Received: from natnoddy.rzone.de (natnoddy.rzone.de [81.169.145.166])
by mx9.evanzo-server.de (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) with ESMTP id
i8IJXcw21748
for <xxx>; Sat, 18 Sep 2004 21:33:40 +0200
Received: from gauss (pD9EA804A.dip0.t-ipconnect.de [217.234.128.74])
by post.webmailer.de (8.12.10/8.12.10) with ESMTP id i8IJXIH0012016
for xxx; Sat, 18 Sep 2004 21:33:22 +0200 (MEST)
Message-ID: <xxx>
From: <xxx>
To: <xxx>
Subject: MySubject
Date: Sat, 18 Sep 2004 21:33:20 +0200
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
X-Spam-Status: No, hits=2.3 required=10.0
tests=RCVD_IN_NJABL,RCVD_IN_ORBS,RCVD_IN_OSIRUSOFT _COM,
X_NJABL_DIALUP
version=2.52
X-Spam-Level: **
X-Spam-Checker-Version: SpamAssassin 2.52 (1.174.2.8-2003-03-24-exp)
X-UIDL: 5e42bc8d65dfb8aca23346a5d08ca308
MyBody
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.