dcsimg
Sending Mail with Jar
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Reginald_Carter
Posted On:   Saturday, September 29, 2007 02:59 PM

Hello- I'm having a problem with sending MultiPart email messages. I'm using JDeveloper 10g.(10.1.3) The funny thing is when I'm in the IDE and send the e-mail it works fine. When I send using my JAR file I get the following error: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_28235257.1190603782578" The pertinent code is as follows: // Setting the Subject and Content Type msg.setSubject(subject); if (att.length() != 0) { //If there are any attachments we have them in the String Array   More>>

Hello-
I'm having a problem with sending MultiPart email messages.
I'm using JDeveloper 10g.(10.1.3)
The funny thing is when I'm in the IDE and send the e-mail it works fine.



When I send using my JAR file I get the following error:



IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
boundary="----=_Part_0_28235257.1190603782578"


The pertinent code is as follows:


			
// Setting the Subject and Content Type
msg.setSubject(subject);

if (att.length() != 0) { //If there are any attachments we have them in the String Array 'ATT'
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
String mimetype;
if (bhtm) {
mimetype = new String();
ct=mimetype = "text/html";
mbp1.setDataHandler(new DataHandler(new ByteArrayDataSource(message, ct)));
mbp1.setContent(message, mimetype);

} else {
ct=mimetype = "text/plain";
mbp1.setDataHandler(new DataHandler(new ByteArrayDataSource(message, ct)));
mbp1.setText(message);
}
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
//Now iterate thru the attachments creating a body part for each and add to the Multipart message.(mp)
for (int x = 0; x < ATT.length; x++) {
String theatt = ATT[x];
MimeBodyPart mbp2 = new MimeBodyPart();
// attach the file to the message
FileDataSource fds = new FileDataSource(theatt);
try{
inputstream=fds.getInputStream();
}catch(IOException ioe){System.out.println(ioe.getMessage());}
DataHandler dh;
dh=new DataHandler(new ByteArrayDataSource(inputstream, "application/octet-stream"));
//dh=new DataHandler(fds,"application/octet-stream");

mbp2.setDataHandler(dh);
mbp2.setFileName(fds.getName());

// create the Multipart and add its parts to it
mp.addBodyPart(mbp2);
//MIME part of type "multipart/mixed" contains object of type java.io.ByteArrayInputStream instead of MimeMultipart

}
// add the Multipart to the message

msg.setContent(mp);
// DataHandler.setDataContentHandlerFactory( new UtlMailContentFactory() );
// try{
// inputstream=msg.getInputStream();
// msg.setDataHandler(new DataHandler(new ByteArrayDataSource(inputstream, "multipart/mixed")));
//msg.setDataHandler(new DataHandler(mp, "multipart/mixed"));
// }catch(IOException ioe){System.out.println(ioe.getMessage());}
// set the Date: header
msg.setSentDate(new Date());

} else { //If there are no attachments we don't need a multi-part object so set the message content.
msg.setSentDate(new Date());
if (bhtm){
ct="text/html";
msg.setDataHandler(new DataHandler(new ByteArrayDataSource(message, ct)));
msg.setContent(message, ct);
}
else{
ct="text/plain";
msg.setDataHandler(new DataHandler(new ByteArrayDataSource(message, ct)));
msg.setContent(message, ct);
}
}


Does anyone see anything I'm doing wrong?
My JAR deployment profile contains the JavaBeans Activation Framework file classes,
so there should be no difference in the IDE unless somehow the IDE is providing a DataContentHandler.
Any ideas would be appreciated.


-    <<Less

Re: Sending Mail with Jar

Posted By:   Stephen_McConnell  
Posted On:   Monday, October 1, 2007 06:45 PM

JDeveloper from Oracle may be using a different javamail jar than you are. See if you can find out where their mail jar file is and use it.
About | Sitemap | Contact