You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Jentu Jain <je...@datacert.com> on 2012/03/06 07:52:58 UTC

Retrieve body of the message

Hi,
When a message is moved into IMAP folder, how to retrieve the message text only (no attachments only the mail body as text)?

Regards
------------------------------------
Jentu Jain | Datacert, Inc.

Why are major companies rapidly migrating to Passport?  Find Out Here<http://www.datacert.com/>
[Description: cid:image001.gif@01CBF2C7.283B26D0]<http://www.datacert.com/feed.xml>[Description: cid:image002.gif@01CBF2C7.283B26D0]<http://twitter.com/datacert>


RE: Retrieve body of the message

Posted by Jentu Jain <je...@datacert.com>.
Thanks Loan. I'll try out these options and let you know.

Regards
------------------------------------
Jentu Jain | Datacert, Inc.

Why are major companies rapidly migrating to Passport?  Find Out Here


-----Original Message-----
From: Ioan Eugen Stan [mailto:stan.ieugen@gmail.com] 
Sent: Tuesday, March 06, 2012 4:48 PM
To: James Users List
Subject: Re: Retrieve body of the message

2012/3/6 Jentu Jain <je...@datacert.com>:
> Thanks Stan.

Hi,

Please call me Ioan, Stan is my family name.

> The method getBodyContent() gives MIME message but I need the parsed MIME message. The message may have say images, attachments, text etc.. I just want to get the text(plain or html) part of the message.
>

Use mime4j to parse the message and get the parts that you need [1].
James does the same if it implements the above mentioned IMAP FETCH command.

Looking at class FetchCommandParser from protocols package I believe James supports partial fetch with text see  method addNextElement().

You can find examples of IMAP FETCH commands (with TEXT argument) in the mailbox-integration-tester package. Check the scripts at [2], especially the ones with Fetch*. They are examples of how an imap session between client and server takes place.

I don't know which IMAP FETCH command and args will give you what you need (you'll find out in the RFC :) [3] ) but I think it's possible to get what you need by sending the appropriate IMAP commands, without implementing your own parsing.

If not, please consider adding support for those commands to James.

Regards,

[1] http://james.apache.org/mime4j/usage.html
[2] http://svn.apache.org/repos/asf/james/mailbox-integration-tester/trunk/src/main/resources/org/apache/james/imap/
[3] http://tools.ietf.org/html/rfc3501#section-6.4.5
--
Ioan Eugen Stan
http://ieugen.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



RE: Retrieve body of the message

Posted by Jentu Jain <je...@datacert.com>.
Loan,
The first option of using MimeTokenStream worked. Thanks once again for your guidance,

Regards
------------------------------------
Jentu Jain | Datacert, Inc.

Why are major companies rapidly migrating to Passport?  Find Out Here


-----Original Message-----
From: Ioan Eugen Stan [mailto:stan.ieugen@gmail.com] 
Sent: Tuesday, March 06, 2012 4:48 PM
To: James Users List
Subject: Re: Retrieve body of the message

2012/3/6 Jentu Jain <je...@datacert.com>:
> Thanks Stan.

Hi,

Please call me Ioan, Stan is my family name.

> The method getBodyContent() gives MIME message but I need the parsed MIME message. The message may have say images, attachments, text etc.. I just want to get the text(plain or html) part of the message.
>

Use mime4j to parse the message and get the parts that you need [1].
James does the same if it implements the above mentioned IMAP FETCH command.

Looking at class FetchCommandParser from protocols package I believe James supports partial fetch with text see  method addNextElement().

You can find examples of IMAP FETCH commands (with TEXT argument) in the mailbox-integration-tester package. Check the scripts at [2], especially the ones with Fetch*. They are examples of how an imap session between client and server takes place.

I don't know which IMAP FETCH command and args will give you what you need (you'll find out in the RFC :) [3] ) but I think it's possible to get what you need by sending the appropriate IMAP commands, without implementing your own parsing.

If not, please consider adding support for those commands to James.

Regards,

[1] http://james.apache.org/mime4j/usage.html
[2] http://svn.apache.org/repos/asf/james/mailbox-integration-tester/trunk/src/main/resources/org/apache/james/imap/
[3] http://tools.ietf.org/html/rfc3501#section-6.4.5
--
Ioan Eugen Stan
http://ieugen.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



Re: Retrieve body of the message

Posted by Ioan Eugen Stan <st...@gmail.com>.
2012/3/6 Jentu Jain <je...@datacert.com>:
> Thanks Stan.

Hi,

Please call me Ioan, Stan is my family name.

> The method getBodyContent() gives MIME message but I need the parsed MIME message. The message may have say images, attachments, text etc.. I just want to get the text(plain or html) part of the message.
>

Use mime4j to parse the message and get the parts that you need [1].
James does the same if it implements the above mentioned IMAP FETCH
command.

Looking at class FetchCommandParser from protocols package I believe
James supports partial fetch with text see  method addNextElement().

You can find examples of IMAP FETCH commands (with TEXT argument) in
the mailbox-integration-tester package. Check the scripts at [2],
especially the ones with Fetch*. They are examples of how an imap
session between client and server takes place.

I don't know which IMAP FETCH command and args will give you what you
need (you'll find out in the RFC :) [3] ) but I think it's possible to
get what you need by sending the appropriate IMAP commands, without
implementing your own parsing.

If not, please consider adding support for those commands to James.

Regards,

[1] http://james.apache.org/mime4j/usage.html
[2] http://svn.apache.org/repos/asf/james/mailbox-integration-tester/trunk/src/main/resources/org/apache/james/imap/
[3] http://tools.ietf.org/html/rfc3501#section-6.4.5
-- 
Ioan Eugen Stan
http://ieugen.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Retrieve body of the message

Posted by Jentu Jain <je...@datacert.com>.
Thanks Stan. 
The method getBodyContent() gives MIME message but I need the parsed MIME message. The message may have say images, attachments, text etc.. I just want to get the text(plain or html) part of the message.

Regards
------------------------------------
Jentu Jain | Datacert, Inc.

Why are major companies rapidly migrating to Passport?  Find Out Here



-----Original Message-----
From: Ioan Eugen Stan [mailto:stan.ieugen@gmail.com] 
Sent: Tuesday, March 06, 2012 3:45 PM
To: server-user@james.apache.org
Subject: Re: Retrieve body of the message

Pe 06.03.2012 08:52, Jentu Jain a scris:
> Hi,
> When a message is moved into IMAP folder, how to retrieve the message text only (no attachments only the mail body as text)?
>
> Regards
> ------------------------------------
> Jentu Jain | Datacert, Inc.
>
> Why are major companies rapidly migrating to Passport?  Find Out 
> Here<http://www.datacert.com/>
> [Description: 
> cid:image001.gif@01CBF2C7.283B26D0]<http://www.datacert.com/feed.xml>[
> Description: 
> cid:image002.gif@01CBF2C7.283B26D0]<http://twitter.com/datacert>
>
>


Hello Jentu,

The mailstore implementations for james provides a getBodyContent of type InputStream. This gets all the message. I think it's the IMAP processor's responsibility to parse (with mime4j) the message and give you access to the parts you need.

The IMAP command is FETCH with TEXT argument [1]. I don't know the status of it's implementation in James.

[1] http://tools.ietf.org/html/rfc3501#section-6.4.5

p.s. I may be wrong.

Cheers,
--
Ioan Eugen Stan
http://ieugen.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Retrieve body of the message

Posted by Ioan Eugen Stan <st...@gmail.com>.
Pe 06.03.2012 08:52, Jentu Jain a scris:
> Hi,
> When a message is moved into IMAP folder, how to retrieve the message text only (no attachments only the mail body as text)?
>
> Regards
> ------------------------------------
> Jentu Jain | Datacert, Inc.
>
> Why are major companies rapidly migrating to Passport?  Find Out Here<http://www.datacert.com/>
> [Description: cid:image001.gif@01CBF2C7.283B26D0]<http://www.datacert.com/feed.xml>[Description: cid:image002.gif@01CBF2C7.283B26D0]<http://twitter.com/datacert>
>
>


Hello Jentu,

The mailstore implementations for james provides a getBodyContent of 
type InputStream. This gets all the message. I think it's the IMAP 
processor's responsibility to parse (with mime4j) the message and give 
you access to the parts you need.

The IMAP command is FETCH with TEXT argument [1]. I don't know the 
status of it's implementation in James.

[1] http://tools.ietf.org/html/rfc3501#section-6.4.5

p.s. I may be wrong.

Cheers,
-- 
Ioan Eugen Stan
http://ieugen.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org