Email structure

I have accessed my gmail account and using imap downloaded an email and
saved it too text.

Im wondering why the body of the message is repeated twice when in gmail
the message is not repeated - is this a standard for emails? by the way
my message itself was just a test so doesnt really make sense. One copy
has \r\n for line breaks whilst the other has
.

any reasons for this duplication?

Received: by 10.214.79.10 with HTTP; Sun, 14 Dec 2008 00:20:25 -0800
(PST)

Message-ID:
[email protected]

Date: Sun, 14 Dec 2008 17:20:25 +0900

From: “XXXXX” [email protected]

To: [email protected]

Subject: new receipt

MIME-Version: 1.0

Content-Type: multipart/alternative;

boundary=“----=_Part_24864_15890710.1229242825307”

Delivered-To: [email protected]

------=_Part_24864_15890710.1229242825307

Content-Type: text/plain; charset=ISO-8859-1

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

#title:go shop at 2.30

#value:1450.00

#desc:me and teh fmaily will go shopping at the new 109 shops in

shibuya!!!and it will be great

really want to go and looking forward to oit

lets go

#envelope:

------=_Part_24864_15890710.1229242825307

Content-Type: text/html; charset=ISO-8859-1

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

#title:go shop at 2.30
#value:1450.00
#desc:me and teh fmaily will
go shopping at the new 109 shops in shibuya!!!and it will be
great
really want to go and looking forward to oit
lets
go
#envelope:

------=_Part_24864_15890710.1229242825307–

It’s not repeating the message, it is giving you a text version and a
HTML version of the message. Just create a parse method to rip the two
versions out.

  • matt

ahhh i thought both sections were identical, i didnt notice text and
html tags in there.

can tmail do this parsing for me, dont really want to reinvent the
wheel.i looked in teh docs and did a bit of experimenting in irb but
coudnt find a way to specify if i wanted the whole body or just the text
or html parts of it.

On Dec 14, 2008, at 5:20 AM, Adam A. wrote:

can tmail do this parsing for me, dont really want to reinvent the
wheel.

Sure can.

i looked in teh docs and did a bit of experimenting in irb but
coudnt find a way to specify if i wanted the whole body or just the
text
or html parts of it.

I use some code like the following to find the text portion of a
message in the Ruby gateway code:

 extract_text = lambda do |message_or_part|
   if message_or_part.multipart?
     message_or_part.each_part { |part| extract_text[part] }
   elsif message_or_part.content_type == "text/plain"
     # use message_or_part here…
   end
 end
 extract_text[message]

Hope that helps.

James Edward G. II

Adam A. wrote:

ahhh i thought both sections were identical, i didnt notice text and
html tags in there.

can tmail do this parsing for me, dont really want to reinvent the
wheel.i looked in teh docs and did a bit of experimenting in irb but
coudnt find a way to specify if i wanted the whole body or just the text
or html parts of it.

If you want to do this in a robust way, google for ruby mime

thanks james for your proc. The rdoc for tmail doesnt have details for
all the methods so your example has really helped.

Thank you