Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8043221

Problem sending multipart mail with Java7 Update 55 after creating soapmessage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 7u55
    • xml
    • x86_64
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      JavaMail version 1.5.2

      A DESCRIPTION OF THE PROBLEM :
      After creating soapmessage and adding a attachementpart in separat method JavaMail send multipart without bodyparts. The Email contains only a subject.

      REGRESSION. Last worked in version 7u51


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Properties;
      import javax.mail.BodyPart;
      import javax.mail.Message;
      import javax.mail.Multipart;
      import javax.mail.Session;
      import javax.mail.Transport;
      import javax.mail.internet.InternetAddress;
      import javax.mail.internet.MimeBodyPart;
      import javax.mail.internet.MimeMessage;
      import javax.mail.internet.MimeMultipart;
      import javax.xml.soap.AttachmentPart;
      import javax.xml.soap.MessageFactory;
      import javax.xml.soap.SOAPException;
      import javax.xml.soap.SOAPMessage;

      public class Test {

          String host=null;
          String user="";
          String password=null;
          String from=null;
          String to=null;
             
          public static void main(String[] args) {
              Test t=new Test();
             
              t.user= "user@mydomain.de";
              t.from= "user@mydomain.de";
              t.to= "user@mydomain.de";
              t.user= "user@mydomain.de";
              t.password="topsecret";
              t.host="mail.mydomain.de";
             
              t.sendMail(); //this works
              t.addSoapAttachement();
              t.sendMail(); //after addAttachmentPart to soapmessage it do not work
             
          }
         
          void addSoapAttachement(){
              try {
                  MessageFactory messageFactory = MessageFactory.newInstance();
                  SOAPMessage message = messageFactory.createMessage();
                  AttachmentPart a = message.createAttachmentPart();
                  a.setContentType("binary/octet-stream");
                  message.addAttachmentPart(a);
              } catch (SOAPException e) {
                  e.printStackTrace();
              }
          }
         
          void sendMail() {
             
              Properties props = new Properties();
              props.put("mail.smtp.host", host);
              props.put("mail.smtp.auth", "true");
             
              Session session = Session.getInstance(props);
              session.setDebug(true);
             
              // Define message
              MimeMessage message = new MimeMessage(session);
              try {
                  message.setFrom(new InternetAddress(from));
                  message.addRecipients(Message.RecipientType.TO, to);
                  message.setSubject("das ist ein multipart test");

                  Multipart multipart = new MimeMultipart();

                  BodyPart messageBodyPart1 = new MimeBodyPart();
                  messageBodyPart1.setText("bitte auch diesen Content senden");
                  multipart.addBodyPart(messageBodyPart1);
                 
                  BodyPart messageBodyPart2 = new MimeBodyPart();
                  messageBodyPart2.setContent("<b>bitte</b> auch diesen Content senden<br>ciau", "text/html; charset=UTF-8");
                  multipart.addBodyPart(messageBodyPart2);
             
                  message.setContent(multipart);
                 
                  Transport tr = session.getTransport("smtp");
                  tr.connect(host,user, password);
                  tr.sendMessage(message,InternetAddress.parse(to));
                  tr.close();
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              coffeys Sean Coffey
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: