E
emrefan
I had somebody sent me an email (using good old Outlook '97 - don't
ask) and this email has the following headers:
Received: by chk_exchange6.whatever.local
id <01C83718.A96E9AC0@chk_exchange6.whatever.local>; Wed, 5 Dec 2007
16:27:24 +0800
Message-ID:
<E839E45C64CF7E4D9E4E8A334B79363001F0DB62@chk_exchange6.whatever.local>
From: "Some guy" <[email protected]>
To: "me" <[email protected]>
Subject: excel attached
Date: Wed, 5 Dec 2007 16:27:24 +0800
MIME-Version: 1.0
Content-Type: application/vnd.ms-excel;
name="nevermind.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="nevermind.xls"
Now, I have a java program that uses the javamail API to recieve a
mail of mime type multipart/mixed and extracts the attached Excel file
from it and it's working nicely. But if the email in question is one
like the above-mentioned, my program fails. So, has anybody got
experience handling a mail of the above type?
The following code is what I used for handling a multipart/mixed mail:
Multipart mimeMsg = (Multipart) aryInMsg[ msgNdx ].getContent();
for (int partNdx=0; partNdx < mimeMsg.getCount(); partNdx++) {
Part part = mimeMsg.getBodyPart( partNdx );
String disp = part.getDisposition();
String attachFilename = part.getFileName();
if (disp != null && disp.equals( Part.ATTACHMENT ) &&
(attachFilename.endsWith( ".xls" ) ||
attachFilename.endsWith( ".XLS" ))) {
System.err.println( "From " + primeSender +
", attached file " +
attachFilename );
File ordFil = new File( uplFilDirPath +
"/ord-" + chkoutDateY4md + ".xls" );
if (ordFil.exists()) {
System.err.println( "Order file " + uplFilDirPath + "/" +
attachFilename + " is a duplicate -> rejected" );
}
OutputStream os = new FileOutputStream( ordFil );
part.writeTo( os );
}
}
ask) and this email has the following headers:
Received: by chk_exchange6.whatever.local
id <01C83718.A96E9AC0@chk_exchange6.whatever.local>; Wed, 5 Dec 2007
16:27:24 +0800
Message-ID:
<E839E45C64CF7E4D9E4E8A334B79363001F0DB62@chk_exchange6.whatever.local>
From: "Some guy" <[email protected]>
To: "me" <[email protected]>
Subject: excel attached
Date: Wed, 5 Dec 2007 16:27:24 +0800
MIME-Version: 1.0
Content-Type: application/vnd.ms-excel;
name="nevermind.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="nevermind.xls"
Now, I have a java program that uses the javamail API to recieve a
mail of mime type multipart/mixed and extracts the attached Excel file
from it and it's working nicely. But if the email in question is one
like the above-mentioned, my program fails. So, has anybody got
experience handling a mail of the above type?
The following code is what I used for handling a multipart/mixed mail:
Multipart mimeMsg = (Multipart) aryInMsg[ msgNdx ].getContent();
for (int partNdx=0; partNdx < mimeMsg.getCount(); partNdx++) {
Part part = mimeMsg.getBodyPart( partNdx );
String disp = part.getDisposition();
String attachFilename = part.getFileName();
if (disp != null && disp.equals( Part.ATTACHMENT ) &&
(attachFilename.endsWith( ".xls" ) ||
attachFilename.endsWith( ".XLS" ))) {
System.err.println( "From " + primeSender +
", attached file " +
attachFilename );
File ordFil = new File( uplFilDirPath +
"/ord-" + chkoutDateY4md + ".xls" );
if (ordFil.exists()) {
System.err.println( "Order file " + uplFilDirPath + "/" +
attachFilename + " is a duplicate -> rejected" );
}
OutputStream os = new FileOutputStream( ordFil );
part.writeTo( os );
}
}