code: public void sendWithAttachment(String subject, 
                                   String textBody,
                                   String attachmentType,
                                   String attachmentName,
                                   InputStream is)
    {
      try {
        MimeMessage msg = new MimeMessage(getSession());
  
        if(_from.length > 0)
          msg.addFrom(_from);
        msg.addRecipients(RecipientType.TO, _to);
        if(subject != null)
          msg.setSubject(subject);
        
        // msg.setContent(textBody, "multipart/mime");
        
        MimeMultipart multipart = new MimeMultipart();
        
        MimeBodyPart textBodyPart = new MimeBodyPart();
        textBodyPart.setText(textBody);
        multipart.addBodyPart(textBodyPart);
        
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        TempBuffer tb = TempBuffer.create();
        byte []buffer = tb.buffer();
        int len;
        
        while ((len = is.read(buffer, 0, buffer.length)) >= 0) {
          bos.write(buffer, 0, len);
        }
        bos.close();
        byte []content = bos.toByteArray();
        TempBuffer.free(tb);
        
        DataSource dataSource
          = new ByteArrayDataSource(content, attachmentType);
        
        MimeBodyPart pdfBodyPart = new MimeBodyPart();
        pdfBodyPart.setDataHandler(new DataHandler(dataSource));
        pdfBodyPart.setFileName(attachmentName);
        multipart.addBodyPart(pdfBodyPart);
        
        msg.setContent(multipart);
  
        send(msg);
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
docs: Sends to a mailbox