title: Retrieve the generated Message-ID before sending email using Spring JavaMail
body: <p>I am using <code>org.springframework.mail.javamail.JavaMailSender</code> to send email using SMTP and in that I need to retrieve the Message-ID header. The below code </p>
  
  <pre><code>message.getMimeMessage().getMessageID()  
  </code></pre>
  
  <p>is returning null. How to retrieve the Message-ID?</p>
  
  <pre><code>public void notifyByMail(final NotificationRequest request)
  {
      MimeMessagePreparator preparator = new MimeMessagePreparator()
      {
          public void prepare(MimeMessage mimeMessage) throws Exception
          {
              MimeMessageHelper message = null;
              message = new MimeMessageHelper(mimeMessage, UTF_8);
              message.setTo(request.getTo());
              message.setCc(request.getCc());
              message.setFrom(request.getFrom());
              message.setReplyTo(request.getReplyTo());
              message.setSubject(request.getSubject());
              message.setText("some text", true);
  
              //Need to retrieve the Message-ID here
              System.out.println("Message - ID : " + message.getMimeMessage().getMessageID());
          }
  
      };
      getMailSender().send(preparator);
  }
  </code></pre>