I'm looking for sample code that shows how to add a FormFile object as an attachment to a javax.mail.internet.MimeMessage object. All examples I have seen are using servlets and a File object, which I can't really use.
I know I can derive an InputStream from FormFile.getInputStream, and that the MimeBodyPart class takes an InputStream as a constructor, but I can't get the header information to make sense. Whenever I send the email, the attachment doesn't show up.
Here's some pseudo code that I have so far (attachment is a FormFile object): ==========================================
Message message = new MimeMessage( session ); message.setFrom( new InternetAddress( address, name ) ); message.setRecipient( Message.RecipientType.BCC, ia ); message.setSubject(subject);
Hi, I dont have exact idea. But in my application i was using Java Mail API for sending a mail with attachment. My requirement was to create a file at runtime and then send it as an attachment to multiple users. I have used java mail api only. Its very simple . When we download it , we will get example . I think that will be helpful for you.