title: javamail problem: how to attach file without creating file
body: <p>I'm using javamail API to create e-mail and attach a file to it.</p>
  
  <p>Is there a way to send e-mail with attach using javamail api
  without physically creating file on file system. </p>
  
  <p>I just want to pick some data from app
  and attach it as file in my e-mail </p>
  
  <p>How should I attach:</p>
  
  <pre><code>try {
              // create a message
              MimeMessage msg = new MimeMessage(session);
              msg.setFrom(new InternetAddress(from));
              InternetAddress[] address = {new InternetAddress(to)};
              msg.setRecipients(Message.RecipientType.TO, address);
              msg.setSubject(subject);
  
              // create and fill the first message part
              MimeBodyPart mbp1 = new MimeBodyPart();
              mbp1.setText(msgText1);
  
              // create the second message part
              MimeBodyPart mbp2 = new MimeBodyPart();
  
              // attach the file to the message
              **mbp2.attachFile(filename);**
  
  
              // create the Multipart and add its parts to it
              Multipart mp = new MimeMultipart();
              mp.addBodyPart(mbp1);
              mp.addBodyPart(mbp2);
  
              // add the Multipart to the message
              msg.setContent(mp);
  
              // set the Date: header
              msg.setSentDate(new Date());
  
              // send the message
              Transport.send(msg);
  </code></pre>
  
  <p>TY very much all !</p>