Problem reading Multiparts in 1.4.1ea
I am using the following simple test program to print out the content
type field for multiparts:
// .. import statements ...
/**
* Simple test for multipart emails.
*/
publicclass SimpleEmailReader{
/** Debug the Content Type field, adds spaces for indenting */
privatestaticvoid debugPart(Part p,int indent)throws IOException, MessagingException{
String contentType = p.getContentType();
for(int j=0; j<indent; j++){
System.out.print(" ");
}
System.out.println("Content-Type=" + contentType);
Object content = p.getContent();
if(contentinstanceof Multipart){
Multipart multipart = (Multipart)content;
int multipartCount = multipart.getCount();
for(int i=0; i<multipartCount; i++){
BodyPart bodyPart = multipart.getBodyPart(i);
debugPart(bodyPart, indent + 1);
}
}
}
publicstaticvoid main(String[] args){
try{
if(args.length < 3){
System.out.println(
"usage: java -classpath ><classpath> SimpleEmailReader <server> <user> <password>");
return;
}
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props,null);
Store store = session.getStore("imap");
store.connect(args[0], args[1], args[2]);
Folder defaultFolder = store.getDefaultFolder();
Folder inbox = defaultFolder.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
Message message = inbox.getMessage(1);
debugPart(message, 0);
inbox.close(false);
}
catch(Exception e){
e.printStackTrace();
}
}
}
I am attempting to read the following message from Exchange IMAP
interface (ip addresses and server names have been changed to
protect the innocent). This is a simple message with the subject "test"
and body "test message". Outlook has created some multiparts since
it is Rich Text.
Received: from xxxxxx.xxxxxx.xx.xxxxxxx.com ([12.345.6.78]) by XXXXXXXXX.xxxxx.xx.xxxxxxx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Apr 2007 12:42:16 -0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="-_=_NextPart_001_01C782A1.B0266400"
Received: from xyz.xxxxxxxx.com ([12.345.678.901]) by xxxxxx.xxxxxx.xx.xxxxxxx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Apr 2007 12:42:15 -0400
Received: from xxxxxx.xxxxxx.xx.xxxxxxx.com ([12.345.678.901]) by xxxxxx.xxxxxx.xx.xxxxxxx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Apr 2007 12:42:14 -0400
Content-class: urn:content-classes:message
Return-Path: <jsender@abc.xyz.com>
X-MimeOLE: Produced By Microsoft Exchange V6.5
X-OriginalArrivalTime: 19 Apr 2007 16:42:14.0127 (UTC) FILETIME=[AF0897F0:01C782A1]
Subject: test message
Date: Thu, 19 Apr 2007 12:42:13 -0400
Message-ID: <BDDB6BE0289D2D46817A4A982676054102AF93B3@xxxxxx.xxxxxx.xx.xxxxxxx.com>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Topic: test message
Thread-Index: AceCoa5xfFvk+l8kQJeeP029JoSmHQ==
From:"Sender, Joe" <jsender@xx.zyz.com>
To:"JOERECIPIENT" <jrecipient@xx.xyz.com>
This is a multi-part message in MIME format.
_=_NextPart_001_01C782A1.B0266400
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
test
_=_NextPart_001_01C782A1.B0266400
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7651.59">
<TITLE>test message</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=3D2 FACE=3D"Arial Unicode MS">test</FONT>
</P>
</BODY>
</HTML>
_=_NextPart_001_01C782A1.B0266400--
When I use 1.4, it correctly detects the nested multiparts and prints out:
Content-Type=multipart/alternative;
boundary="-_=_NextPart_001_01C782A5.97B84880"
Content-Type=TEXT/PLAIN; charset=iso-8859-1
Content-Type=TEXT/HTML; charset=iso-8859-1
However, when I use 1.4.1ea, it only detects the main multipart and not the contents:
Content-Type=multipart/alternative;
boundary="-_=_NextPart_001_01C782A5.97B84880"
Any suggestions?
# 1
I just uploaded a new version of 1.4.1ea, try that if you can.Also, try using the msgshow.java demo program to display the message.Use the -D option to print the protocol trace and post it or send it tojavamail@sun.com for more help.
# 2
I retrieved the 1.4.1ea source again from the Maven repository just to make sure I have the latest code (posted on 4/18), from this URL:
https://maven-repository.dev.java.net/nonav/repository/javax.mail/java-sources/mail-1.4.1ea-SNAPSHOT-sources.jar
I ran it using the following command line options:
-T imap -H myserver.xxx.com -U joeuser -P password -v -D -s -m
This is where it gets even more strange. When I give msgshow.java the "-m" option to show the message, the code blocks at this line in the msgshow.java and does not return from this call:
msg = new MimeMessage(session, msgStream);
Specifically, it is blocking on the in.read() call here:while ((c1 = in.read()) != -1) {
which is at this stack trace:
LineInputStream.readLine() line: 75
InternetHeaders.load(InputStream) line: 329
InternetHeaders.<init>(InputStream) line: 301
MimeMessage.createInternetHeaders(InputStream) line: 2060
MimeMessage.parse(InputStream) line: 318
MimeMessage.<init>(Session, InputStream) line: 196
msgshow.main(String[]) line: 136
Could it be possible that the IMAP service is not completing the response(?) Our program does not use this version of the constructor: MimeMessage(Session, InputStream), so I haven't seen this problem before - I have only seen the blocking using msgshow.java. Also, it blocks in this way using both 1.4.1ea and also 1.4, so this is not the same problem described above -- the original problem I posted with (Multiparts not being parsed) is only a problem in 1.4.1ea, not 1.4.
The original multipart problem occurs with a very basic message sent from Outlook. I'm suprised no one else is seeing this problem, which suggests to me that maybe virus detection software is tampering with the message.
# 3
Also, since msgshow.java stopped in a blocked state, the session debugging only returned this:
DEBUG: setDebug: JavaMail version 1.4.1ea-SNAPSHOT
(when I ran it using 1.4.1ea), and it only returned:
DEBUG: setDebug: JavaMail version 1.4ea
...when using what I thought was 1.4, but apparently is 1.4ea. The DEBUG value shown conflicts with the manifest.mf file, which indicates:
Implementation-Version: 1.4(not "1.4ea")
# 4
The -m option to msgshow tells it to read the message from stdinrather than connect to the server.(The version number in the debug output for JavaMail 1.4 iswrong - it says "1.4ea" even though it's really 1.4.)
# 5
Ok, it looks in msgshow.java that if "-D" option is set, it expects the message to either come from a file or from System.in.
So "-D" won't work unless you set "-f INBOX" (dumps to a file called INBOX, and uses the same variable to get the INBOX folder. So that explains the blocking problem. Now back to the original issue...
# 6
> Ok, it looks in msgshow.java that if "-D" option is
> set, it expects the message to either come from a
> file or from System.in.
That's not true, what made you believe that?
} else if (argv[optind].equals("-D")) {
debug = true;
# 7
Sorry, I meant to say "-m" does this - if "-f" is set, it uses data from the file, otherwise System.in:
if (showMessage) {
MimeMessage msg;
if (mbox != null)
msg = new MimeMessage(session,
new BufferedInputStream(new FileInputStream(mbox)));
else
msg = new MimeMessage(session, msgStream);
dumpPart(msg);
System.exit(0);
}
To show this problem I just need a simple program which reads a message from INBOX, and prints multipart information (like the program above). The msgshow program seems to want data from either System.in or a file. If I dump the message content to a file (using Message.writeTo()), then try to read the data in from that file using msgshow, I get the following output:
<prints a lot of numbers within brackets such as [82][101][99][101][105][118]>
<then, prints the message header fields, then>
Oops, got exception! javax.mail.util.SharedByteArrayInputStream
java.lang.ClassCastException: javax.mail.util.SharedByteArrayInputStream
at msgshow.dumpPart(msgshow.java:303)
at msgshow.main(msgshow.java:138)
# 8
Correction, the stack trace is as follows:
Oops, got exception! javax.mail.util.SharedByteArrayInputStream
java.lang.ClassCastException: javax.mail.util.SharedByteArrayInputStream
at msgshow.dumpPart(msgshow.java:289)
at msgshow.main(msgshow.java:137)
This is using the msgshow.java from JavaMail 1.4. Is there an updated msgshow.java that goes with 1.4.1ea? I did not see it in the maven download.
# 9
Run with the -D option and post the protocol trace. Is it still the case that 1.4 works and 1.4.1 fails?And you're using Microsoft Exchange, right?And all you do is switch the mail.jar file that you're using?
# 10
Both protocol traces, using JavaMail 1.4 and 1.4.1ea (domain names changed):
protocol trace from 1.4
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (NYOBGCEXMB21.uswin.ad.myinternal.com) ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: protocolConnect login, host=NYOBGCEXMB21.uswin.ad.myinternal.com, user=wfmtest, password=<non-null>
A1 LOGIN wfmtest openme1
A1 OK LOGIN completed.
DEBUG: connection available -- size: 1
A2 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A2 OK [READ-WRITE] SELECT completed.
A3 LIST "" INBOX
* LIST (\Marked \HasNoChildren) "/" INBOX
A3 OK LIST completed.
Total messages = 1
New messages = 0
-
A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (X-Mailer)])
* 1 FETCH (ENVELOPE ("Wed, 25 Apr 2007 15:52:14 -0400" "test" (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("WFMTEST" NIL "wfmtest" "se.mycompany.com")) NIL NIL NIL "<BDDB6BE0289D2D46817A4A982676054102AF93CA@gaalpexmb25.uswin.ad.myinternal.com>") INTERNALDATE "25-Apr-2007 15:52:14 -0400" RFC822.SIZE 2005 FLAGS () BODY[HEADER.FIELDS (X-Mailer)] {2}
)
A4 OK FETCH completed.
--
MESSAGE #1:
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
A5 EXAMINE INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS ()] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A5 OK [READ-ONLY] EXAMINE completed.
A6 CLOSE
A6 OK CLOSE completed.
DEBUG: added an Authenticated connection -- size: 1
A7 LOGOUT
* BYE Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 signing off.
A7 OK LOGOUT completed.
DEBUG: IMAPStore connection dead
DEBUG: IMAPStore cleanup, force false
DEBUG: IMAPStore cleanup done
protocol trace from 1.4.1ea
DEBUG: setDebug: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc.,1.4.1ea-SNAPSHOT]
DEBUG: mail.imap.fetchsize: 16384
* OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (NYOBGCEXMB21.uswin.ad.myinternal.com) ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: protocolConnect login, host=NYOBGCEXMB21.uswin.ad.myinternal.com, user=wfmtest, password=<non-null>
A1 LOGIN wfmtest openme1
A1 OK LOGIN completed.
A2 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A2 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: connection available -- size: 1
A3 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A3 OK [READ-WRITE] SELECT completed.
Total messages = 1
New messages = 0
-
A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (X-Mailer)])
* 1 FETCH (ENVELOPE ("Wed, 25 Apr 2007 15:52:14 -0400" "test" (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("WFMTEST" NIL "wfmtest" "se.mycompany.com")) NIL NIL NIL "<BDDB6BE0289D2D46817A4A982676054102AF93CA@gaalpexmb25.uswin.ad.myinternal.com>") INTERNALDATE "25-Apr-2007 15:52:14 -0400" RFC822.SIZE 2005 FLAGS () BODY[HEADER.FIELDS (X-Mailer)] {2}
)
A4 OK FETCH completed.
[13]--
MESSAGE #1:
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
A5 EXAMINE INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS ()] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A5 OK [READ-ONLY] EXAMINE completed.
A6 CLOSE
A6 OK CLOSE completed.
DEBUG: added an Authenticated connection -- size: 1
A7 LOGOUT
* BYE Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 signing off.
A7 OK LOGOUT completed.
DEBUG: IMAPStore connection dead
DEBUG: IMAPStore cleanup, force false
DEBUG: IMAPStore cleanup done
# 11
I don't see the failure. Am I missing it?
# 12
This time I printed the multiparts, so you can see the exception in the 1.4.1ea trace:
Protocol trace for JavaMail 1.4
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (NYOBGCEXMB21.uswin.ad.myinternal.com) ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: protocolConnect login, host=NYOBGCEXMB21.uswin.ad.myinternal.com, user=wfmtest, password=<non-null>
A1 LOGIN wfmtest openme1
A1 OK LOGIN completed.
DEBUG: connection available -- size: 1
A2 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A2 OK [READ-WRITE] SELECT completed.
A3 LIST "" INBOX
* LIST (\Marked \HasNoChildren) "/" INBOX
A3 OK LIST completed.
Total messages = 1
New messages = 0
-
A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (X-Mailer)])
* 1 FETCH (ENVELOPE ("Wed, 25 Apr 2007 15:52:14 -0400" "test" (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("WFMTEST" NIL "wfmtest" "se.mycompany.com")) NIL NIL NIL "<BDDB6BE0289D2D46817A4A982676054102AF93CA@gaalpexmb25.uswin.ad.myinternal.com>") INTERNALDATE "25-Apr-2007 15:52:14 -0400" RFC822.SIZE 2005 FLAGS () BODY[HEADER.FIELDS (X-Mailer)] {2}
)
A4 OK FETCH completed.
--
MESSAGE #1:
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
A5 FETCH 1 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 14 1 NIL NIL NIL)("TEXT" "HTML" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 401 7 NIL NIL NIL) "alternative" ("boundary" "-_=_NextPart_001_01C78773.38EAC001") NIL NIL))
A5 OK FETCH completed.
CONTENT-TYPE: multipart/alternative;
boundary="-_=_NextPart_001_01C78773.38EAC001"
This is a Multipart
CONTENT-TYPE: TEXT/PLAIN; charset=iso-8859-1
This is plain text
CONTENT-TYPE: TEXT/HTML; charset=iso-8859-1
A6 EXAMINE INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS ()] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A6 OK [READ-ONLY] EXAMINE completed.
A7 CLOSE
A7 OK CLOSE completed.
DEBUG: added an Authenticated connection -- size: 1
A8 LOGOUT
* BYE Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 signing off.
A8 OK LOGOUT completed.
DEBUG: IMAPStore connection dead
DEBUG: IMAPStore cleanup, force false
DEBUG: IMAPStore cleanup done
Protocol trace for JavaMail 1.4.1ea
DEBUG: setDebug: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc.,1.4.1ea-SNAPSHOT]
DEBUG: mail.imap.fetchsize: 16384
* OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (NYOBGCEXMB21.uswin.ad.myinternal.com) ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: protocolConnect login, host=NYOBGCEXMB21.uswin.ad.myinternal.com, user=wfmtest, password=<non-null>
A1 LOGIN wfmtest openme1
A1 OK LOGIN completed.
A2 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
A2 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
DEBUG: connection available -- size: 1
A3 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 1] Is the first unseen message
* OK [UIDVALIDITY 101262] UIDVALIDITY value
A3 OK [READ-WRITE] SELECT completed.
Total messages = 1
New messages = 0
-
A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (X-Mailer)])
* 1 FETCH (ENVELOPE ("Wed, 25 Apr 2007 15:52:14 -0400" "test" (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("Hitt, Joseph" NIL "c0hittj" "se.mycompany.com")) (("WFMTEST" NIL "wfmtest" "se.mycompany.com")) NIL NIL NIL "<BDDB6BE0289D2D46817A4A982676054102AF93CA@gaalpexmb25.uswin.ad.myinternal.com>") INTERNALDATE "25-Apr-2007 15:52:14 -0400" RFC822.SIZE 2005 FLAGS () BODY[HEADER.FIELDS (X-Mailer)] {2}
)
A4 OK FETCH completed.
[13]--
MESSAGE #1:
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
This is the message envelope
FROM: "Hitt, Joseph" <c0hittj@se.mycompany.com>
TO: WFMTEST <wfmtest@se.mycompany.com>
SUBJECT: test
SendDate: Wed Apr 25 15:52:14 EDT 2007
FLAGS:
X-Mailer NOT available
A5 FETCH 1 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 14 1 NIL NIL NIL)("TEXT" "HTML" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 401 7 NIL NIL NIL) "alternative" ("boundary" "-_=_NextPart_001_01C78773.38EAC001") NIL NIL))
A5 OK FETCH completed.
CONTENT-TYPE: multipart/alternative;
boundary="-_=_NextPart_001_01C78773.38EAC001"
This is a Multipart
Oops, got exception! com.sun.mail.imap.IMAPInputStream
java.lang.ClassCastException: com.sun.mail.imap.IMAPInputStream
at msgshow.dumpPart(msgshow.java:288)
at msgshow.main(msgshow.java:225)
# 13
Sorry for the confusion, to clarify:- The problem only occurs when getting the individual multiparts.- The problem only occurs in 1.4.1ea, not 1.4.1.
# 14
Are you using the mail.jar binary from the java.net repository,or are you building it yourself from source? If the latter, are youusing the source code and ant build file from GlassFish, or areyou using the source code from the maven repository?
# 15
For 1.4, I used the mail.jar downloaded from the JavaMail site.
For 1.4.1ea, I downloaded source from the maven repository, and built that (whatever was there last week). I can download it again if needed, or download from a prebuilt jar.
I used the msgshow.java from 1.4 (because the demo directory did not come with the maven download - perhaps it is somewhere else). Let me know if I should get a different version of msgshow.java that specifically comes with 1.4.1ea.
In case the line numbers are off, the exception is being thrown when calling getContent in the bold line below:
pr("This is a Multipart");
pr("");
Multipart mp = (Multipart)p.getContent();
level++;
int count = mp.getCount();
# 16
So much time we could've saved if you'd mentioned a few of these
things up front. You're several standard deviations beyond the
typical question asked in this forum...
The source code in the maven repository is good for debugging
the code that's in the binary jar file. It's not sufficient to rebuild
the binary. In particular, it's missing the non-Java source files
that are configuration files used by JavaMail. If you want to build
from source, get it from the GlassFish CVS repository and use
the included ant build file.
Download the pre-built jar file and try that. I'm sure it will work.
Sorry I didn't figure this out more quickly...
# 17
No prob, sorry again for the confusion.As for downloading the pre-built 1.4.1ea javamail, is there any place to do that without downloading glassfish? (Tried installing glassfish b44 thinking that might have it, but the installer hangs).
# 18
Disregard previous posting - (I was trying to extract glassfish.class, which doesn't work). I have the prebuilt jar containing the following JavaMail version from the glassfish b44 build:Implementation-Version: 1.4.1ea-SNAPSHOTI'll try that out and post findings later
# 19
Thanks, that solved the problem in this posting. Must have been an incorrect maping of the message encoding, due to the missing config files.