try this

for (int i =0; i < 2; i++)
{
        // This is for displaying the name of the attachment
        String attach = (String)attachmentArrayList.get(i);

        int start = attach.lastIndexOf("/");
        nameOfAttachment = attach.substring(start+1);

        System.out.println(nameOfAttachment);
        // This part of the code is for attaching the file to the message
        messageBodyPart = new MimeBodyPart();
        source = new FileDataSource(attach);
        messageBodyPart.setDataHandler(new DataHandler(source));

        /* The name of attachment which is to be displayed is set.
         */
        messageBodyPart.setFileName(nameOfAttachment.trim());
        multipart.addBodyPart(messageBodyPart);
}

Regards,
Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-1031


-----Original Message-----
From: Daniel Jayapaul [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 4:53 AM
To: [EMAIL PROTECTED]
Subject: Multiple Attacments(JavaMail)


Hi

I am trying to send multiple attachments at a single time
I tried this ..did not work

what should I do ?



for(int i=0;i<2;i++) {
      String filename = "c:/example.txt";

      // attach the file to the message
     FileDataSource fds = new FileDataSource(filename);
     mbp2.setDataHandler(new DataHandler(fds));
     mbp2.setFileName(fds.getName());

      //  if (filename == "c:/example.txt") filename = "c:/test.txt";
     // create the Multipart and its parts to it
     Multipart mp = new MimeMultipart();
     mp.addBodyPart(mbp1);
     mp.addBodyPart(mbp2);

     // add the Multipart to the message
     msg.setContent(mp);

     }
     //msg.setHeader("X-Mailer", mailer);
     msg.setSentDate(new Date());


Thanks ...!!!!
Daniel.E

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to