Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Error occured during attachment of file using java.

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error occured during attachment of file using java.

    I want to attach some files using java in my Email Application.SO i used Multipart class but i got some error like this.....
    Exception caught 
    javax.mail.MessagingException: IOException while sending message;
      nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
        boundary="----=_Part_0_31510384.1309567547673"
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:625)
        at javax.mail.Transport.send0(Transport.java:169)
        at javax.mail.Transport.send(Transport.java:98)
        at MultipartExample.<init>(MultipartExample.java:43)
        at MultipartExample.main(MultipartExample.java:53)
    Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
        boundary="----=_Part_0_31510384.1309567547673"
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:891)
        at javax.activation.DataHandler.writeTo(DataHandler.java:317)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1350)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1683)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:585)
        ... 4 more


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Error occured during attachment of file using java.

    This thread may help (from googling for 'no object DCH for MIME type multipart/mixed').

    I don't usually act like a Google front-end, but I'm in a good mood...

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error occured during attachment of file using java.

    @dlorde I have done lot of googling but still i am not able to fix the error can you tell me how to fix that issue.
    Please i have to do continue my project help me guy's !!

  4. #4
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Error occured during attachment of file using java.

    So did none of the solutions in the thread I linked to work?

    Please post up the code you tried for them.

  5. #5
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error occured during attachment of file using java.

    yeh why not.....actually i am trying to do a simple Multipart program
    check this code...
    import java.util.Properties;
    /*import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Authenticator;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import javax.mail.Multipart;
    import javax.mail.MimeMultipart;
    import javax.mail.BodyPart;
    import javax.mail.MimeBodyPart;*/
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class MultipartExample
    {
    MultipartExample()
    {
    try
    {
    Properties properties=System.getProperties();
    properties.setProperty("mail.smtp.host","smtp.gmai l.com");
    properties.setProperty("mail.smtp.port","587");
    properties.setProperty("mail.smtp.auth","true");
    properties.setProperty("mail.smtp.starttls.enable" ,"true");
    Session session=Session.getDefaultInstance(properties,new MyAuthentication());
    Message message=new MimeMessage(session);
    message.setFrom(new InternetAddress("morning.com.hablu@gmail.com"));
    message.addRecipient(Message.RecipientType.TO,new InternetAddress("kaliyaodi@gmail.com"));
    message.setSubject("Multipart message");
    Multipart multipart=new MimeMultipart();
    BodyPart bodypart=new MimeBodyPart();
    bodypart.setText("Can you get this message....?");
    bodypart.setDataHandler(new DataHandler("hiiiii","text/plain"));
    //BodyPart bodypart1=new MimeBodyPart();
    //bodypart1.setText("My name is");
    multipart.addBodyPart(bodypart);
    //message.setContent(multipart,"text/html; charset=UTF-8");
    //multipart.addBodyPart(bodypart1);
    //message.setContent("hekkdjjdj", "text/html; charset=UTF-8");
    message.setContent(multipart);
    Transport.send(message);
    }
    catch(Exception e)
    {
    System.out.println("Exception caught ");
    e.printStackTrace();
    }
    }
    public static void main(String args[])
    {
    new MultipartExample();
    }
    class MyAuthentication extends Authenticator
    {
    MyAuthentication()
    {
    super();
    }
    protected PasswordAuthentication getPasswordAuthentication()
    {
    return new PasswordAuthentication("morning.com.hablu","rockan dhack");
    }
    }
    }
    But don't know why it will throw the above exception.
    Help me please !!

  6. #6
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Error occured during attachment of file using java.

    OK - you clearly aren't going to tell me what you tried from the link, so let's do it the long way:

    1 - did you make sure mail.jar and activation.jar and in your appserver are compatible versions ? (this seems to be the most common problem)
    2 - are the jars in the same directory?
    3 - the code you posted doesn't show the MailCap MIME handler initialization - did you try that - can you post the code you used for it?

    p.s. this is my last attempt, I really don't have the time to mess about.

Similar Threads

  1. Replies: 1
    Last Post: June 9th, 2011, 08:51 AM
  2. Soap With Attachment AXIS Fault
    By anoopasta in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 23rd, 2010, 11:09 AM
  3. Java error while Playing Video file.
    By ravigirismiles in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 7th, 2010, 11:09 AM
  4. Please solve my error occured java.lang.NullPointerExceptio
    By Viruthagiri in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: March 24th, 2010, 08:29 AM
  5. Javamail attachment filenames
    By johniem in forum Java Theory & Questions
    Replies: 0
    Last Post: February 3rd, 2010, 07:51 AM