tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stuart Stephen" <stuart.step...@talkics.com>
Subject RE: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html
Date Thu, 27 Nov 2003 17:36:55 GMT
Hi,

Ever since trying to attach files to HTML e-mails I have had this problem.

I've just checked my mailcap file and this seems fine to me??? Or at least
it is according to http://www.jguru.com/faq/view.jsp?EID=237257. The
contents of my mailcap file is below.

-------------------------------
#
# @(#)mailcap	1.5 00/09/26
#
# Default mailcap file for the JavaMail System.
#
# JavaMail content-handlers:
#
text/plain;;		x-java-content-handler=com.sun.mail.handlers.text_plain
text/html;;		x-java-content-handler=com.sun.mail.handlers.text_html
text/xml;;		x-java-content-handler=com.sun.mail.handlers.text_xml
multipart/*;;		x-java-content-handler=com.sun.mail.handlers.multipart_mixed
message/rfc822;;	x-java-content-handler=com.sun.mail.handlers.message_rfc822

-------------------------------
My email sending code is below:

  private static boolean sendMessage(String[] to, String subject, String
message, String from, String[] filelocation) {
    try {
      String recievers = StringWizard.arrayToText(to, ", ");
      ContentType ct = new ContentType("text/plain", "iso-8859-1", new
ParameterList());
      StringBuffer msg = new StringBuffer(message);

      Properties prop = new Properties();
      prop.put("mail.smtp.auth", "true");
      prop.put("mail.transport.protocol", "smtp");
      prop.put("mail.smtp.host", MAIL_HOST);

      Session mail_Session=Session.getInstance(prop, null);
      InternetAddress fromAddress = new InternetAddress(from);
      InternetAddress toAddress[] = new InternetAddress[to.length];

      for(int i=0;i<to.length;i++) toAddress[i] = new
InternetAddress(to[i]);

      InternetAddress[] reply = { fromAddress };

      MimeMessage myMessage = new MimeMessage(mail_Session);
      myMessage.setFrom(fromAddress);
      myMessage.setReplyTo(reply);

      for(int i=0;i<to.length;i++)
myMessage.addRecipient(Message.RecipientType.TO, toAddress[i]);

      myMessage.setSentDate(new java.util.Date());
      myMessage.setSubject(subject);

      Multipart mp = new MimeMultipart();

      // add default stuff (text).
      // add text.
      MimeBodyPart textpart = new MimeBodyPart();
      textpart.setText(msg.toString());
      mp.addBodyPart(textpart);

      // add html.
      boolean sendHTML = UserHelper.HTMLEmails(to[0]);
      if(sendHTML) {
        MimeBodyPart htmlpart = new MimeBodyPart();

htmlpart.setContent(StringWizard.stripJavascript(StringWizard.toHTML(msg.toS
tring())), "text/html" + " (" + msg.length() + " chars)");
        mp.addBodyPart(htmlpart);
      }

      // if we are sending any files with this email add them.
      boolean attached = false;
      if(filelocation!=null && filelocation.length>0) {
        for(int i=0;i<filelocation.length;i++) {
          File attachment = new File(filelocation[i]);
          if(attachment.exists() && attachment.isFile() &&
attachment.canRead()) {
            System.err.println("Email.sendMessage() : Attaching file " +
attachment.getAbsolutePath() + " to email bound for " + recievers);
            MimeBodyPart attachfile = new MimeBodyPart();
            FileDataSource fds = new FileDataSource(attachment);
            DataHandler dh = new DataHandler(fds);
            attachfile.setFileName(attachment.getName());
            attachfile.setDisposition(Part.ATTACHMENT);
            attachfile.setDescription("Attached File: " +
attachment.getName());
            attachfile.setDataHandler(dh);
            mp.addBodyPart(attachfile);
            attached = true;
          }
        }
      }

      if(attached==false && !sendHTML)myMessage =
addMessageHeaders(myMessage, ct);
      myMessage.setContent(mp);

      Transport tr = mail_Session.getTransport("smtp");
      tr.connect(MAIL_HOST, USERNAME, PASSWORD);

      myMessage.saveChanges();

      tr.sendMessage(myMessage, toAddress);
      tr.close();
      return true;
    }
    catch(Exception e){
      e.printStackTrace(System.err);
      return false;
    }
  }

-----Original Message-----
From: Stuart Stephen [mailto:stuart.stephen@talkics.com]
Sent: 27 November 2003 16:47
To: tomcat-user@jakarta.apache.org
Subject: javax.activation.UnsupportedDataTypeException: no object DCH
for MIME type text/html


Hi,

I'm getting the following error when sending HTML emails. From looking
around the web it appears that my error could be from my mailcap file not
being configured correctly, or the include order of mail.jar and
activation.jar. How can I find out in which order Tomcat includes jars?

Has anyone encountered these errors before and know a fix?

Thanks
Stuart

javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
text/html (844 chars)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:353)
	at com.t2ut.email.Email.sendMessage(Email.java:246)
	at com.t2ut.email.Email.sendMail(Email.java:50)
	at
org.apache.jsp.tcr_update_list_jsp._jspService(tcr_update_list_jsp.java:157)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:684)
	at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch
er.java:575)
	at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher
.java:498)
	at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:8
22)
	at org.apache.jsp.tcr_view_jsp._jspService(tcr_view_jsp.java:76)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:684)
	at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch
er.java:575)
	at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher
.java:498)
	at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:8
22)
	at org.apache.jsp.tcr_jsp._jspService(tcr_jsp.java:98)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
	at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
	at java.lang.Thread.run(Thread.java:484)



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message