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 2 of 2

Thread: sending multiPart mail through yahoo mail cause javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default sending multiPart mail through yahoo mail cause javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

    It have been long since I asked for help on the forums but latly I have been Struggling with this problem for a couple of days.
    read all the forums did all ppl did but no change.
    What the H I am doing wrong ?
    by the way I am using javamail 5.1 and java 8 and already send text msg so no problem with properties

    here is my code


    // Get system properties
        Properties properties = System.getProperties();
        // Setup mail server
        properties.put("mail.smtp.starttls.enable", "true");
        properties.put("mail.smtp.host", mailHost);
        properties.put("mail.smtp.user", mailUserName);
        properties.put("mail.smtp.password", mailPassword);
        properties.put("mail.smtp.port", "587");
        properties.put("mail.smtp.auth", "true");
     
        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);
     
        try{
            // Create a default MimeMessage object.
            MimeMessage message = new MimeMessage(session);
     
            // Set From: header field of the header.
            message.setFrom(new InternetAddress(mD.mailUserName));
     
            // Set To: header field of the header.
            message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
     
            Multipart multiPart = new MimeMultipart();
            MimeBodyPart textPart = new MimeBodyPart();
            textPart.setText("This is actual message", "text/html; charset=utf-8");
     
            MimeBodyPart htmlPart = new MimeBodyPart();
            htmlPart.setContent(html, "text/html; charset=utf-8");
            multiPart.addBodyPart(textPart);
            multiPart.addBodyPart(htmlPart);
            message.setContent(multiPart);
     
            // Send message
            Transport transport = session.getTransport("smtp");
            transport.connect( mD.mailHost,mD.mailUserName,mD.mailPassword);
     
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader( javax.mail.Session.class.getClassLoader() );
            try
            {
                message.setContent(multiPart);
                //transport.sendMessage(message, message.getAllRecipients());
                Transport.send(message, message.getAllRecipients());
            }
            catch (MessagingException e)
            {
                e.printStackTrace();
            }
            finally
            {
                Thread.currentThread().setContextClassLoader(classLoader);
            }
            transport.close();
        }
        catch (MessagingException mex)
        {
            mex.printStackTrace();
        }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: sending multiPart mail through yahoo mail cause javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

    Welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.

Similar Threads

  1. Error sending email using javax.mail : SMTP can only send RFC822 messages
    By greraume in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 20th, 2014, 09:17 AM
  2. javax.mail.AuthenticationFailedException after few days
    By Rekha_d in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 14th, 2014, 11:44 PM
  3. javax.mail
    By ambareeshsurendran in forum Java Theory & Questions
    Replies: 1
    Last Post: May 22nd, 2013, 04:46 PM
  4. javax.mail--------------whats the problem
    By ambareeshsurendran in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 22nd, 2013, 02:08 PM
  5. Javax.Mail Query Help Me Please
    By ravjot28 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 19th, 2010, 11:06 AM

Tags for this Thread