Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^3: receiving email message with an attachment.

by ig (Vicar)
on Feb 28, 2013 at 04:39 UTC ( #1020987=note: print w/replies, xml ) Need Help??

in reply to Re^2: receiving email message with an attachment.
in thread receiving email message with an attachment.

Where the body is depends on how the message is composed. Can you post a small but complete example of a message you are having trouble parsing?

For example, here are relevant bits of a message generated by Outlook, with an attachment:

From - Thu Feb 28 17:29:24 2013
Subject: test
Date: Thu, 28 Feb 2013 04:28:38 +0000
Message-ID: <>
Accept-Language: en-NZ, en-US
Content-Language: en-US
X-MS-Has-Attach: yes
Content-Type: multipart/mixed;
MIME-Version: 1.0

Content-Type: multipart/alternative;

Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

This is the body of the message.

Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"" xmlns=3D"http:=
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<body lang=3D"EN-NZ" link=3D"blue" vlink=3D"purple">

This is the body of the message.<o:p></o:p>

</body> </html> --_000_E24D1C1D2311AC43AA14ACFD05622B7694917BCHEXCHMBX01cloudh_-- --_004_E24D1C1D2311AC43AA14ACFD05622B7694917BCHEXCHMBX01cloudh_ Content-Type: text/plain; name="test.txt" Content-Description: test.txt Content-Disposition: attachment; filename="test.txt"; size=40; creation-date="Thu, 28 Feb 2013 04:28:39 GMT"; modification-date="Thu, 28 Feb 2013 04:28:52 GMT" Content-Transfer-Encoding: base64 VGhpcyBpcyBhIHRleHQgZmlsZSwgYXMgYW4gYXR0YWNobWVudC4NCg== --_004_E24D1C1D2311AC43AA14ACFD05622B7694917BCHEXCHMBX01cloudh_--

In this case, the first part of the multipart message has the body of the message twice: first as plain text and then as an HTML formatted message.

But your messages may be quite different from this.

  • Comment on Re^3: receiving email message with an attachment.

Replies are listed 'Best First'.
Re^4: receiving email message with an attachment.
by tenny1204 (Novice) on Feb 28, 2013 at 06:50 UTC

    I red somewhere that all mime entities consisted of a (mime::)head and a (mime::)body, but apparently its not(entirely) true. I'll try some more on my own. Thank you.

      You can read all about it in RFC2045 and related RFCs. Each part of a multipart message has both headers and body.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020987]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-06-23 12:24 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.