Need help with Tmail parser

Hey,

I’m new to Ruby and I need some help to finish my task. Basically I’m
getting a string from db which is an email content.

The string is as follows :

MIME-Version: 1.0
Content-Transfer-Encoding: 8-bit
Content-Type: multipart/mixed; boundary="__AWSQUEUE__RMWFETWJOGMKIVYQ"

This is a multi-part message in MIME format.

--__AWSQUEUE__RMWFETWJOGMKIVYQ
Content-Type: text/plain

[KUMO][TEST] Automated Selenium test 2013/04/18 15:37:49 1366299469495
--__AWSQUEUE__RMWFETWJOGMKIVYQ—

Now I want to parse the above string for body using MIME parse.
Here is my code:
mail=TMail::Mail.parse(tempCommText)
body = mail.body.to_s

This is where I’m running into problem. The parser is having some
problem with empty lines/white line characters.
Error Message:
ERROR: undefined method `blank?' for
{"boundary"=>"\"__AWSQUEUE__RMWFETWJOGMKIVYQ\""

So I thought of replacing them using gsub(/^[\s]*$\n/, '') but I’m
running into below issue.
ERROR -- : ERROR: wrong mail header: '"This is a multi-part message in
MIME format.\n"'

This thing is really blocking my work and any help is appreciated.
Thanks in advance.

···

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

Hey,

I’m new to Ruby and I need some help to finish my task. Basically I’m
getting a string from db which is an email content.

The string is as follows :

MIME-Version: 1.0
Content-Transfer-Encoding: 8-bit
Content-Type: multipart/mixed; boundary="__AWSQUEUE__RMWFETWJOGMKIVYQ"

This is a multi-part message in MIME format.

--__AWSQUEUE__RMWFETWJOGMKIVYQ
Content-Type: text/plain

[KUMO][TEST] Automated Selenium test 2013/04/18 15:37:49 1366299469495

The following line may be in error:

--__AWSQUEUE__RMWFETWJOGMKIVYQ—

The last character looks more like an m-dash rather than a pair of minuses.

When I changed it to:

--__AWSQUEUE__RMWFETWJOGMKIVYQ--

It worked fine.

···

On Fri, Apr 19, 2013 at 11:12 AM, Deepak Mallapu <lists@ruby-forum.com> wrote:

Now I want to parse the above string for body using MIME parse.
Here is my code:
mail=TMail::Mail.parse(tempCommText)
body = mail.body.to_s

This is where I’m running into problem. The parser is having some
problem with empty lines/white line characters.
Error Message:
ERROR: undefined method `blank?' for
{"boundary"=>"\"__AWSQUEUE__RMWFETWJOGMKIVYQ\""

So I thought of replacing them using gsub(/^[\s]*$\n/, '') but I’m
running into below issue.
ERROR -- : ERROR: wrong mail header: '"This is a multi-part message in
MIME format.\n"'

This thing is really blocking my work and any help is appreciated.
Thanks in advance.

--
Posted via http://www.ruby-forum.com/\.

Looks like I figured out the problem. The parser is breaking only when
the email type is mixed/multipart.

May be I'm trying to parse some attachment. Looks like I fixed my issue.
Thanks :slight_smile:

···

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