[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

email structure

Adam Akhtar

12/14/2008 9:50:00 AM

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:
<c4e168850812140020v7a36ce13s456d0ffa55f797a0@mail.gmail.com>

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

From: "XXXXX" <XXXXX@gmail.com>

To: XXXXX@gmail.com

Subject: new receipt

MIME-Version: 1.0

Content-Type: multipart/alternative;

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

Delivered-To: XXXXX@gmail.com



------=_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--
--
Posted via http://www.ruby-....

5 Answers

calcop

12/14/2008 10:00:00 AM

0

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
--
Posted via http://www.ruby-....

Adam Akhtar

12/14/2008 11:21:00 AM

0

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.

--
Posted via http://www.ruby-....

James Gray

12/14/2008 11:34:00 PM

0

On Dec 14, 2008, at 5:20 AM, Adam Akhtar 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 =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


Adam Akhtar

12/15/2008 11:29:00 AM

0

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

Thank you
--
Posted via http://www.ruby-....

Brian Candler

12/15/2008 11:51:00 AM

0

Adam Akhtar 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
--
Posted via http://www.ruby-....