2012/3/20 Saibabu Vallurupalli <[email protected]>:
> Hi Eric,
>
> We are trying to retrieve it after storing to make it more simple. During
> process might need a code change in mailets I guess.
> If it is a completed email in BLOB, is there a way to extract just
> attachment?
>
> Thanks, Sai
>

Hello Say,

You will have to load the email and use mime4j to process it and
extract attachments. The code that maps one message to a database
table is in JPAMessage class [1]. If you look closely, you will see
the JPA annotations for headers and body like bellow. JPAMessage class
has getBodyContent and getHeaderContent methods to get an InputStream
for each value.

5       /** The value for the body field. Lazy loaded */
46      /** We use a max length to represent 1gb data. Thats prolly
overkill, but who knows */
47      @Basic(optional = false, fetch = FetchType.LAZY)
48      @Column(name = "MAIL_BYTES", length = 1048576000, nullable = false)
49      @Lob private byte[] body;

52      /** The value for the header field. Lazy loaded */
53      /** We use a max length to represent 1gb data. Thats prolly
overkill, but who knows */
54      @Basic(optional = false, fetch = FetchType.LAZY)
55      @Column(name = "HEADER_BYTES", length = 10485760, nullable = false)
56      @Lob private byte[] header;


[1] 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java?view=markup

> On Tue, Mar 20, 2012 at 3:23 PM, Eric Charles <[email protected]> wrote:
>
>> Hi Sai,
>> If you use JPA, the complete mail is stored as a blob in the JAMES_MESSAGE
>> table (see http://james.apache.org/**server/3/images/database/**
>> james-database-schema-derby_**1000.png<http://james.apache.org/server/3/images/database/james-database-schema-derby_1000.png>for
>>  an old version of the schema).
>>
>> Are you looking to extract it when processing the mail in a mailet, or
>> extract afterwards when already stored in the database? The implementations
>> will be quite different depending on your need.
>>
>> Thx, Eric
>>
>>
>>
>> On 20/03/12 20:00, Saibabu Vallurupalli wrote:
>>
>>> Hi Team,
>>>
>>> At present I have a requirement to extract the email attachment and put
>>> them in a separate folder for different use.
>>>
>>> What is the best way to do this? Does the attachments are stored in MySQL
>>> database?
>>>
>>> Any inputs on this will be really helpful.
>>>
>>> Thank you,
>>> Sai
>>>
>>>
>> --
>> eric | http://about.echarles.net | @echarles
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: 
>> server-dev-unsubscribe@james.**apache.org<[email protected]>
>> For additional commands, e-mail: 
>> [email protected].**org<[email protected]>
>>
>>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to