473,769 Members | 3,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.D E16FB30"
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_6 0,HTML_MESSAGE, RCVD_IN_NJABL,R CVD_IN_ORBS,
RCVD_IN_OSIRUSO FT_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: a80fd03ed87acc5 f2ff1c427fcd9d8 f4

This is a multi-part message in MIME format.

------=_NextPart_000_ 003F_01C49DC6.D E16FB30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MyBody
------=_NextPart_000_ 003F_01C49DC6.D E16FB30
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"MSHT ML 6.00.2800.1458" name=3DGENERATO R>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffff ff>
<DIV>&nbsp;</DIV>MyBody</BODY></HTML>

------=_NextPart_000_ 003F_01C49DC6.D E16FB30--
"

"+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_N JABL,RCVD_IN_OR BS,RCVD_IN_OSIR USOFT_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: 5e42bc8d65dfb8a ca23346a5d08ca3 08
MyBody
Nov 18 '05 #1
0 2341

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

Similar topics

2
10687
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 APP.length My goal is to simply write a xml file out a javascript array... Thanks for any help !!
12
3879
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
5
2766
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 into a string, the \x0095 are interpreted literally. However, the following code works fine: - string a = "\x0095 blah1 \x0095 blah2 \x0095 blah3 \x0095 blah4";
10
25840
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
20587
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. who can give me some ideas? The following is my program, but it has some problem. I hope someone would correct it. //////////////////////////// //Test_ConvertArg.c ////////////////////////////
2
10927
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
5767
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 know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
11
3542
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 returns a elementtree, on which you can then apply xpath; 2) To parse a string (xml section), you can call XML or fromstring, but both return element instead of elementtree. This alone is bad. To make it worse, you have to create an elementtree from...
3
2617
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. ------------------------------------- I have a console app that accepts input from the user. This input can be a command for the application, or a mathematical equation/formula. Currently, I'm using a trick I found on the Internet that creates a dynamic JScript assembly, loads...
4
2399
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 element that is causing the grief? Sorry to post the entire object, but Im hoping someone has a parse utility that will help find whats wrong. { "TABLE":}, { "COL":"},{"DATA":"Education includes a BA in psychology from Colorado State University in...
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.