Is there a way to validate completeness of a message fetched from IMAP folder?

View: New views
2 Messages — Rating Filter:   Alert me  

Is there a way to validate completeness of a message fetched from IMAP folder?

by saurabhd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I plan to use JavaMail for one of my projects, where I need to download some emails from a IMAP store (gmail), and move them to a issue tracking system.

Is there a way to validate that email was downloaded / fetched with no corruptions (or partial downlaods)?

I understand from a response at stack overflow that "The IMAP protocol will tell you how many octets are going to be transfered when you issue the FETCH command.". Is there a way in JavaMail to get the value of "how many octects are going to be transfered", so I can cross check the file, once JavaMail API returns a success for a fetch?

I also found getContentMD5 in IMAPMessage class. Do all IMAP servers support this? i.e. can I get the contentMD5 before fetching the message and then compare it to ensure completeness of the email?
http://java.sun.com/products/javamail/javadocs/com/sun/mail/imap/IMAPMessage.html#getContentMD5()

Thanks
Saurabh

Re: Is there a way to validate completeness of a message fetched from IMAP folder?

by Bill Shannon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

saurabhd wrote:
> I plan to use JavaMail for one of my projects, where I need to download some
> emails from a IMAP store (gmail), and move them to a issue tracking system.
>
> Is there a way to validate that email was downloaded / fetched with no
> corruptions (or partial downlaods)?

No.  Although generally you'll get an exception if there's a problem.

The biggest problems are usually *not* undetected corruption of the data,
but rather failures or bugs in the mail server.

> I understand from a response at stack overflow that "The IMAP protocol will
> tell you how many octets are going to be transfered when you issue the FETCH
> command.". Is there a way in JavaMail to get the value of "how many octects
> are going to be transfered", so I can cross check the file, once JavaMail
> API returns a success for a fetch?

You can use the getSize method, but see all the caveats in the javadocs.

> I also found getContentMD5 in IMAPMessage class. Do all IMAP servers support
> this? i.e. can I get the contentMD5 before fetching the message and then
> compare it to ensure completeness of the email?

Not all messages will include it.

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVAMAIL-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".