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> </DIV><BR> 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--