Can't get rid of "no object DCH for MIME"
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_Michel
Posted On:   Friday, May 30, 2003 08:34 AM

I am using javamail to send messages with attachments from a standalone app. Everything works fine from within the IDE and if I run the app from it's .class files, for instance : C:mautoclassesmauto>java -classpath ..;..mail.jar;..iText.jar;..activation.jar mauto.ui.App But when I try to bundle it in a jar file, I keep getting this nasty "no object DCH for MIME" exception when sending mail. I have read about this issue but all solutions seem to work for everyone but me. So far I have done the following, to no avail : 1. Include the contents of mail.jar and activation.jar in my own jar (this worked with iText, and seems to work with mail.jar, but not with activation.jar) 2.   More>>


I am using javamail to send messages with attachments from a standalone app. Everything works fine from within the IDE and if I run the app from it's .class files, for instance :


C:mautoclassesmauto>java -classpath ..;..mail.jar;..iText.jar;..activation.jar mauto.ui.App


But when I try to bundle it in a jar file, I keep getting this nasty "no object DCH for MIME" exception when sending mail. I have read about this issue but all solutions seem to work for everyone but me. So far I have done the following, to no avail :


1. Include the contents of mail.jar and activation.jar in my own jar (this worked with iText, and seems to work with mail.jar, but not with activation.jar)

2. Added a Class-Path entry for activation.jar in my manifest (I guess activation.jar should be in the same directory as my jar, right?)

3. Put activation.jar in CLASSPATH

4. Put activation.jar in jre/lib/ext


What am I missing?


I'm using jdk 1.3.1_08, javamail 1.3, jaf 1.0.2, win2k


The code is straightforward, but just in case :

			

try
{

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", txHost.get());

// Get session

Session session = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(txFrom.get()));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(txTo.get()));
message.setSubject(txSubject.get());

BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(txBody.getText());

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);

// attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(lbAttach.getText());
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(lbAttach.getText());
multipart.addBodyPart(messageBodyPart);

// Put parts in message
message.setContent(multipart);

// Send message
Transport.send(message);

}
catch (Exception ex)
{
Alert.error(ex.getMessage(), "Error en el envĂ­o");
ex.printStackTrace();
return ;
}





Regards

Peter

   <<Less

Solved

Posted By:   Peter_Michel  
Posted On:   Saturday, May 31, 2003 08:06 AM

Ok, I tried out some more bizarre things, but in the end I created a simple class to invoke the application, which is still "jared", but since I no longer use the -jar option I'm now my -classpath is no longer ignored. It works.


Life is beautiful.

Regards

Peter
About | Sitemap | Contact