How do I send an email with attachment?


In this example we create a small program to send email with a file attachment. To send message with attachment we need to create an email with javax.mail.Multipart object which basically will contains the email text message and then add a file to the second block, which both of them is an object of javax.mail.internet.MimeBodyPart. In this example we also use the javax.activation.FileDataSource.

  • Maddur Krishna Chiatanya

    Hi.. I followed your code its works for me… but i want file name as dynamic i.e user uploaded file as attchment..iam using strust1.x … please help me