email structure

A

Adam Akhtar

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 <br>.

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: (e-mail address removed)

Subject: new receipt

MIME-Version: 1.0

Content-Type: multipart/alternative;

boundary="----=_Part_24864_15890710.1229242825307"

Delivered-To: (e-mail address removed)



------=_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<br>#value:1450.00<br>#desc:me and teh fmaily will
go shopping at the new 109 shops in shibuya!!!and it will be
great<br>really want to go and looking forward to oit<br>lets
go<br>#envelope:<br><br>



------=_Part_24864_15890710.1229242825307--
 
M

Matt Do

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
 
A

Adam Akhtar

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.
 
J

James Gray

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 =20=
text
or html parts of it.

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

extract_text =3D 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 =3D=3D "text/plain"
# use message_or_part here=85
end
end
extract_text[message]

Hope that helps.

James Edward Gray II
 
A

Adam Akhtar

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

Thank you
 
B

Brian Candler

Adam said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top