title: Multiple addInline() in MimeMessagePreparator()
body: <p>I want to add multiple images in my mail</p>
  
  <pre><code>String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "email-template.vm", module);
              message.setText(text, true);
  
              message.addInline("img001", new ClassPathResource("/myPath/image001.jpg"));
              message.addInline("img002", new ClassPathResource("/myPath/image002.jpg"));
  </code></pre>
  
  <p>but I have a NullPointerException !</p>
  
  <pre><code>org.springframework.mail.MailPreparationException: Could not prepare mail; nested exception is java.lang.NullPointerException
  at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:369) [spring-context-support-2.5.6.SEC01.jar:2.5.6.SEC01]
  at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:346) [spring-context-support-2.5.6.SEC01.jar:2.5.6.SEC01]
  </code></pre>
  
  <p>and when I add just one image (addInline()) all goes well and the mail is sent</p>
  
  <p>anyone have an idea ? Thank's</p>
  
  <p>edit:</p>
  
  <p>I figured out how to send an email with multiple images inside</p>
  
  <pre><code>    MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage,MimeMessageHelper.MULTIPART_MODE_RELATED,"UTF-8");
                      message.setTo(TO);
                      message.setFrom(FROM);
      MimeBodyPart part = new MimeBodyPart();
      String body = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,"template.vm","UTF-8",module);
      part.setContent(body,"text/html");
  // Create a new part for the attached image and set the CID image identifier
      MimeBodyPart imagePart = new MimeBodyPart();
      FileDataSource fds = new FileDataSource("C:/path/image001.jpg");
      imagePart.setDataHandler(new DataHandler(fds));
      imagePart.setHeader("Content-ID", "resImg1");
  
      MimeBodyPart imagePart2 = new MimeBodyPart();
      FileDataSource fds2 = new FileDataSource("C:/image002.jpg");
      imagePart2.setDataHandler(new DataHandler(fds2));
      imagePart2.setHeader("Content-ID", "resImg2");
  
      Multipart mp = new MimeMultipart();
  
      mp.addBodyPart(part);
      mp.addBodyPart(imagePart);
      mp.addBodyPart(imagePart2);
  
      // Set the message's content
      mimeMessage.setContent(mp);
      }
  };
  this.mailSender.send(preparator);
  </code></pre>
  
  <p>In template.vm for insert images : <code>&lt;img width=172 height=40 src="cid:resImg1"alt="Image1"/&gt;</code></p>
  
  <p>I hope help someone</p>