473,385 Members | 1,764 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,385 software developers and data experts.

Regexp and parsing .eml file in details problem

Hello,

Is anyone have an example of RegExp expression to parse .EML files (Email
Message)? I need to extract headers, HTML body, Textual body and attachments
if any exists.

I did some example, but not sure that its a good start:

^Message-ID: (?<messageid>.*)\nFrom: (?<from>.*)\nTo: (?<to>.*)\nSubject:
(?<subject>.*)\nDate: (?<date>.*)\nMIME-Version: (?<mime>.*)\nContent-Type:
(?<contenttype>.*)\n

And the test message file was:
Received: from ([127.0.0.1]) with arachnoMail.NET Server; Sat, 06 Mar 2004
05:19:49 -0800
Message-ID: <00****************************@test.vpn>
From: Test <te**@test.vpn>
To: Test <te**@test.vpn>
Subject: bg_stripe.gif
Date: Sat, 6 Mar 2004 12:24:06 +0200
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0005_01C40375.EB4919F0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C40375.EB4919F0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0006_01C40375.EB4919F0"
------=_NextPart_001_0006_01C40375.EB4919F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

bg_stripe.gif
------=_NextPart_001_0006_01C40375.EB4919F0
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.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp;</DIV><BR>&nbsp;bg_stripe.gif</BODY></HTML>

------=_NextPart_001_0006_01C40375.EB4919F0--

------=_NextPart_000_0005_01C40375.EB4919F0
Content-Type: image/gif;
name="bg_stripe.gif"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="bg_stripe.gif"

R0lGODlhBgALAIAAAABQn////yH5BAQUAP8ALAAAAAAGAAsAAAIKjI8Gy+0P40s0FAA7

------=_NextPart_000_0005_01C40375.EB4919F0--
Nov 20 '05 #1
0 1610

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

Similar topics

19
by: Magnus Lie Hetland | last post by:
I'm working on a project (Atox) where I need to match quite a few regular expressions (several hundred) in reasonably large text files. I've found that this can easily get rather slow. (There are...
5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
1
by: geos | last post by:
hello, I have the problem writing the regular expression to verify the valid system path in the way that RegExp.$1 has to contain path up to the parent folder of a file, and RegExp.$2 should...
19
by: Dr Clue | last post by:
I'm not really an expert with RegExp() , although I do use it. The problem I have is that I want to strip comments out of a CSS file using RegExp() The reason is that I'm loading and parsing to...
4
by: conan | last post by:
This regexp '<widget class=".*" id=".*">' works well with 'grep' for matching lines of the kind <widget class="GtkWindow" id="window1"> on a XML .glade file However that's not true for the...
27
by: SQL Learner | last post by:
Hi all, I have an Access db with two large tables - 3,100,000 (tblA) and 7,000 (tblB) records. I created a select query using Inner Join by partial matching two fields (X from tblA and Y from...
11
by: Flyzone | last post by:
Hello, i have again problem with regexp :-P I need to match all lines that contain one word but not contain another. Like to do "grep one | grep -v two:" The syntax of the string is: (any...
13
by: otrWalter | last post by:
I'm trying to display that type, name and value to class properties. Yes, I know about print_r(). I'm just trying to build a display format for this information. AFAIK, the standard PHP tools to...
3
by: =?Utf-8?B?RGFuYQ==?= | last post by:
I am re-posting this message after registering my posting alias. When I specify an end tag for the clear element of namespaces in my web.config file, the parser error "Unrecognized element 'add'"...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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,...
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
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...

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.