Hi Sun:
    This is the code to send multipart thru javamail API . This send
text/html as multiparts.

=============

         // create properties
      Properties props = new Properties();
      props.put( EMAIL_SMTP_HOST, m_host );

      // get the default session
      Session session = Session.getDefaultInstance( props, null );

      // create a message
      Message message = new MimeMessage( session );

      // set From
      message.setFrom( new InternetAddress( m_sender ) );

      // set Recipient
      InternetAddress address = new InternetAddress( m_recipient );
      message.setRecipient( Message.RecipientType.TO, address );

      // blind carbon copy to confirm sent out email
      if ( m_bcc.length() != 0 )
      {
        InternetAddress bccAddress = new InternetAddress( m_bcc );
        message.setRecipient( Message.RecipientType.BCC, bccAddress );
      }

      // set Subject
      message.setSubject( m_subject );

      // set SentDate
      message.setSentDate( Calendar.getInstance().getTime() );

      // set Context
      // message.setContent( m_content, MIME_TYPE );

      // Added to send mail in multipart/alternate
      // part1: text , part2: html
      // create and fill the first message part
           MimeBodyPart mbp1 = new MimeBodyPart();
           mbp1.setText(m_content_part1);

           // create and fill the second message part
           MimeBodyPart mbp2 = new MimeBodyPart();
           // pass DataHandler object wrapped with message body
           mbp2.setDataHandler(new DataHandler(
           new ByteArrayDataSource(m_content_part2, "text/html")));

        // create the Multipart and its parts to it
            MimeMultipart mp = new MimeMultipart();
            mp.addBodyPart(mbp1);
            mp.addBodyPart(mbp2);
            mp.setSubType("alternative");

            // add the Multipart to the message
            message.setContent(mp);

      // send message
      Transport.send( message );


Hope this helps

--Asha

-----Original Message-----
From: Sun JunXu [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 06, 2000 11:14 PM
To: [EMAIL PROTECTED]
Subject:


hi,
I am using javamail to write a servlet, in servlet,  a line of code like as
following:
File smAttachedfile=new File("/home/bba.jpg");
MimeBodyPart mbp2=new MimeBodyPart();
mbp2.setContent(smAttachedfile,"image/jpg");

then get error message below:
Sending failed; nested exception is: javax.mail.MessagingException:
IOException while sending message; nested exception is:
 javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
image/jpg.

How can I resolve this problem? by ther way : what does DCH stand for?

Thank you very much for any helps.

sincerely
sun

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to