• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How to send Email with 2 or many attached files

Hi Experts

How can i send email  with 2 files attached with it from my JSP Page using JavaMail.

Thanx
0
massrico
Asked:
massrico
  • 2
1 Solution
 
fargoCommented:
0
 
fargoCommented:
for sending multiple files the following may help
File[] attachments=new File{"file1" ,"file2","file3"}

for( int i = 0; i < attachments.length; i++ )
{
    messageBody = new MimeBodyPart();

    FileDataSource fileDataSource =new FileDataSource(attachments[i]);
    messageBody.setDataHandler(new DataHandler(fileDataSource));
    messageBody.setFileName(attachments[i].getName());
           
    multipart.addBodyPart(messageBody);
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now