我正在尝试使用 javax.mail 功能发送带有附件的邮件,下面是我的代码:
// create the message part
MimeBodyPart messageBodyPart = new MimeBodyPart();
// fill message
messageBodyPart.setText(strmessage);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
AdcsipLogger.adcsipLog("begin exportFile...........");
ExportFile exportFile = buildQuestionnaireReport(questionnaire);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new ExportFileDataSource(exportFile);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(questionnaire.getName() + ".pdf");
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message);
我在以下行遇到异常: messageBodyPart.setDataHandler(new DataHandler(source));
以下是堆栈跟踪的摘录:
[10/30/13 14:44:38:089 CET] 00000062 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet QuestionnaireControl in application A430-CADCSIP-V8.0_Run4. Exception created : java.lang.VerifyError: javax/mail/internet/MimeBodyPart.setDataHandler(Ljavax/activation/DataHandler;)V
请帮我。谢谢。