hi

// Set the subject of the mail.
        if(subject != null)
                msg.setSubject(subject);
        else
                msg.setSubject("");


        msg.setSentDate(new Date());

// Sets the text which has to be sent
        messageBodyPart = new MimeBodyPart();

        if(text != null)
                messageBodyPart.setText(text);
        else
                messageBodyPart.setText("");

// Put parts in message
        message.setContent(multipart);


// This code is useful when multiple attachments have to be sent.

        Transport transport = session.getTransport("smtp");
        transport.connect(SERVERADDRESS, "", "");
        transport.sendMessage(msg, msg.getAllRecipients());
        transport.close();

Hope it solves ur problem.
Or you can check out this link for further information.
http://java.sun.com/products/javamail/

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


-----Original Message-----
From: Daniel Jayapaul [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 9:26 PM
To: [EMAIL PROTECTED]
Subject: Message Missing


Hi Vikramjit

The multiple attachment works but I cannot send the message now..,
How do I set the message ?

Everything is fine except the message ...

 // create and fill the first message part
      messageBodyPart = new MimeBodyPart();
      messageBodyPart.setText(message);

      Multipart multipart = new MimeMultipart();

      for (int i =0; i < 2; i++)
      {
        // This is for displaying the name of the attachment
        String nameOfAttachment = "c:/example.txt";
        System.out.println(nameOfAttachment);

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

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

        multipart.addBodyPart(messageBodyPart);
      }

      msg.setContent(multipart);
    // msg.setHeader("X-Mailer", mailer);

     msg.setSentDate(new Date());

===========================================================================
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