tracker issue : CF-3345011

select a category, or use search below
(searches all categories and all time range)
Title:

error "javax.mail.MessagingException: Unable to load BODYSTRUCTURE" when using CFIMAP

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Phil Cruz / Phil Cruz (Phil Cruz)

Created: 10/11/2012

Components: Net Protocols

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Final / CF10_Update14

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 3

Problem Description:
cfimap has an error trying to parse messages that have .eml messages attached in the body. Specifically, if the message is encoded such as 

--0016e6dab04d85220f04cbca474e
Content-Type: message/rfc822; charset=UTF-8
Content-Disposition: attachment
Content-Transfer-Encoding: base64
X-Attachment-Id: 777fe6a5abfcc3e5_0.2

This issue is discussed here as well:
http://www.oracle.com/technetwork/java/javamail/faq/index.html#imapserverbug
http://www.theserverside.com/discussions/thread.tss?thread_id=14042

Steps to Reproduce:

1. Create a message with an .eml attached such that  it is encoded like above. 
2. use this code to access the message
        iMapObj = new imap(); 
    	iMapObj.setAttributes(server="imap.gmail.com",username=supportEmail, password=popMailPassword,secure="yes", connection="imapConnection"); 
    	iMapObj.open(); 
    	qryMailHeaders = iMapObj.getHeaderOnly(connection = "imapConnection");
	iMapObj.close(connection="imapConnection");

Actual Result:

you get an error 
Message: Unable to load BODYSTRUCTURE
		StackTrace: javax.mail.MessagingException: Unable to load BODYSTRUCTURE
			at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1297)
			at com.sun.mail.imap.IMAPMessage.getLineCount(IMAPMessage.java:407)
			at coldfusion.mail.EmailTable.populate(EmailTable.java:138)
			at coldfusion.mail.IMapImpl.getMails(IMapImpl.java:329)
			at coldfusion.tagext.net.IMapTag$1.run(IMapTag.java:541)
			at java.security.AccessController.doPrivileged(Native Method)
			at coldfusion.tagext.net.IMapTag.doStartTag(IMapTag.java:537)
			at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2799)
			at cfbase2ecfc450754003$funcINVOKETAG.runFunction(C:\ColdFusion10\cfusion\CustomTags\com\adobe\coldfusion\base.cfc:566)

Expected Result:
No error.

Any Workarounds:

None.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3345011

External Customer Info:
External Company:  
External Customer Name: Phil.Cruz
External Customer Email:  
External Test Config: Windows 7/64bit and Windows Server 2008 R2/64bit

Attachments:

  1. July 14, 2014 00:00:00: 1_Bug-3345011.pdf

Comments:

Not exactly sure how to create a message encoded as such. If you attach an eml in Gmail, it will encode it differently and it won't be a problem. But I do have a sample messages that will create this problem and can forward to you.
Comment by External U.
17605 | October 11, 2012 10:29:22 AM GMT
Here's another example of an attachment that causes the problem --_004_AC62DD3EF2DB914EB78CFAB9464893C621A26594bospwexchmb02ir_ Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name="LLWC_NewUser_Setup_11Oct2012.xlsx" Content-Description: LLWC_NewUser_Setup_11Oct2012.xlsx Content-Disposition: attachment; filename="LLWC_NewUser_Setup_11Oct2012.xlsx"; size=10561; creation-date="Thu, 11 Oct 2012 20:32:12 GMT"; modification-date="Thu, 11 Oct 2012 20:32:12 GMT" Content-Transfer-Encoding: base64
Comment by External U.
17606 | October 11, 2012 03:06:29 PM GMT
Can you please provide us with the sample message we can type in attachment to reproduce the issue (Comment added from ex-user id:nawani)
Comment by Adobe D.
17607 | September 23, 2013 11:04:55 PM GMT
I'm able to create a message that creates this error now. The eml can be any eml file. I create a new text file in windows. Put in some simple text like "test 1 2 3". I named the file with a .eml extension. Then I used Thunderbird (most recent version as of today) to send a message with the eml file as an attachment. Trying to access the mail produces the error. The destination account is on Gmail. Let me know if you need any other information.
Comment by External U.
17608 | September 26, 2013 05:26:37 PM GMT
Also, check this http://stackoverflow.com/questions/18115854/unable-to-load-bodystructure-exception-with-an-email-containing-an-eml-file-sen Maybe update the version of JavaMail?
Comment by External U.
17609 | September 26, 2013 05:28:50 PM GMT
Same problem here - processing incoming emails. I don't need the attachments - I just need this not to throw an error.
Vote by External U.
17617 | March 20, 2014 11:37:50 AM GMT
This is fixed in CF11 public beta so that's good to know.
Comment by External U.
17610 | March 21, 2014 12:07:45 PM GMT
This error still persists in CF11, getting several of these errors today after rolling out a CF11 application. Unable to load BODYSTRUCTURE javax.mail.MessagingException: Unable to load BODYSTRUCTURE at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1308) at com.sun.mail.imap.IMAPMessage.getLineCount(IMAPMessage.java:422) at coldfusion.mail.EmailTable.populate(EmailTable.java:152) at coldfusion.mail.IMapImpl.getMails(IMapImpl.java:377) at coldfusion.tagext.net.IMapTag$1.run(IMapTag.java:644) at java.security.AccessController.doPrivileged(Native Method) at coldfusion.tagext.net.IMapTag.handleRequest(IMapTag.java:640) at coldfusion.tagext.net.IMapTag.doEndTag(IMapTag.java:533) at cfgroupmanager2ecfc1832461560$funcCHECKMESSAGES._factor11(D:\pbn\code\net\probono\www\com\groupmanager.cfc:53) Only occurs when an email has a .eml file attached. This bug is very annoying, we have to manually delete these emails every time we encounter the issue to get things working again. Any idea when this might be fixed?
Comment by External U.
17611 | July 14, 2014 11:04:36 AM GMT
Need this fixed as soon as possible. Thanks.
Vote by External U.
17618 | July 14, 2014 11:05:23 AM GMT
Yes, it still persists in CF11. It passed my one test case so I thought it was fixed but I did get errors after rolling CF11 into production.
Comment by External U.
17612 | July 14, 2014 11:09:26 AM GMT
I'm glad I found here that I can get it working again after the error, but this is not tenable. Please fix ASAP.
Vote by External U.
17619 | July 14, 2014 11:23:41 AM GMT
we are able to reproduce the given error only in ColdFusion 10 not in ColdFusion 11. I have prepared the message which is encoded as (base64) given in the bug description and also as in one of the comments.Also,I have tried sending an eml file from thunderbird and receiving it using IMAP. ColdFusion 10 is throwing the error "javax.mail.MessagingException: Unable to load BODYSTRUCTURE" when retrieving those emails using CFIMAP. But CF11 able to retrieve the message without any errors. The email account is on GMail. Can you provide the sample message or eml file for which you are getting this error in CF11. I have tried using a simple eml file as you have mentioned, also used thunderbird but no luck. Also, fix will be provided for ColdFusion 10 version.
Comment by S V.
17613 | August 01, 2014 02:30:18 AM GMT
I'm don't know how to create a problem email but I have an email that I received that causes both CF10 and CF11 to choke. In Gmail I can "show original" to get the full headers and save that to a file. How can I send it to you directly? I don't want to attach it here for privacy reasons. to clarify, it's an IMAP error but different from "Unable to load BODYSTRUCTURE". When I run this code iMapObj = new imap(); iMapObj.setAttributes(server="imap.gmail.com",username=gmailAccount, password=passwd,secure="yes", connection="imapConnection", folder=folder); iMapObj.open(); qryMailHeaders = iMapObj.getHeaderOnly(connection = "imapConnection"); writeDump(qryMailHeaders); //writeOutput(qryMailHeaders.uid); newMail = iMapObj.getAll(messageNumber=1); writeDump(newMail); iMapObj.close(); I'm getting: Message: String index out of range: -1 StackTrace: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:797) at java.lang.StringBuffer.replace(StringBuffer.java:391) at coldfusion.mail.EmailTable.removeCids(EmailTable.java:419) at coldfusion.mail.EmailTable.populate(EmailTable.java:294) at coldfusion.mail.IMapImpl.getMails(IMapImpl.java:329) at coldfusion.tagext.net.IMapTag$1.run(IMapTag.java:541) at java.security.AccessController.doPrivileged(Native Method) at coldfusion.tagext.net.IMapTag.doStartTag(IMapTag.java:537) at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2799) at cfbase2ecfc450754003$funcINVOKETAG.runFunction(C:\ColdFusion10\cfusion\CustomTags\com\adobe\coldfusion\base.cfc:566) -Phil
Comment by External U.
17614 | August 04, 2014 12:26:02 PM GMT
You can send it to me directly to sanniset at adobe dot com Looking at the stacktrace you have given seems like this issue is similar to CF-3734319 (CFIMAP action GETALL breaks when there is an email attachment with square brackets). Does any of the email attachment name contains a square bracket ? -Pavan.
Comment by S V.
17615 | August 05, 2014 01:06:49 AM GMT
Yes, there is an attachment with square brackets. --047d7b5d42cebdae7c04ffcefe12-- --047d7b5d42cebdae8104ffcefe14 Content-Type: application/octet-stream; name="[Untitled].pdf" Content-Disposition: attachment; filename="[Untitled].pdf" Content-Transfer-Encoding: base64 Content-ID: <[Untitled].pdf> X-Attachment-Id: d4fb8d5a313aca02_0.1 Since you are aware of the issue I won't send the sample file unless you really want it. Just let me know. -Phil
Comment by External U.
17616 | August 05, 2014 12:39:20 PM GMT