473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to parse multi-part messages in MIME format?

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 21 '05 #1
0 5698

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: iop | last post by:
Hello there, I'd like to "parse" an entire multi-dimension array like this : APP APP without knowing "framework" or "config" or anything passed as variables... 'cause it's simple to call...
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
5
by: David | last post by:
I have an xml file that, for example, contains the following element: - <data>\x0095 blah1 \x0095 blah2 \x0095 blah3 \x0095 blah4</data> If I use XmlTextReader.ReadString() to read this data...
10
by: dreamcatcher | last post by:
I want my program to parse INI files, only have little clue of how to do that, though, hope you guys might shed some light on this, thanx. for example:
19
by: linzhenhua1205 | last post by:
I want to parse a string like C program parse the command line into argc & argv. I hope don't use the array the allocate a fix memory first, and don't use the memory allocate function like malloc....
2
by: kaede | last post by:
Hi all, Given the following textfile (i.e test.txt) 5 5 5 2 E aeiou 4 3 Y abcdefghij
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
11
by: Peter Pei | last post by:
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which...
3
by: Mythran | last post by:
Sorry, this was originally posted in VB.Net newsgroup, but I meant for it to be posted to the C# group initially, so I'm sorry for the multi-post, my mistake. -------------------------------------...
4
by: ShutterMan | last post by:
I have a JSON object as below (data is from SQL Server Northwind Database). But doing an eval on it returns an error "unterminated string constant" or such. Can someone help me pinpoint the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.