Hi Simta.
Thanks for your Reply.
If you need more info on formatting messages.
you can look at MimeMessage Class inside javax.mail.internet package.
Hope this helps you.
Regards
Senthil.
At 04:55 PM 14/09/2001 +0500, you wrote:
>hi
>
>*******************************************************
><<for sending the file as attachment you can use the following code
>********************************************************
>
>
> Properties properties = new Properties();
> properties.put("mail.smtp.host","164.16.1.82");
> properties.put("mail.from","[EMAIL PROTECTED]");
> System.out.println("with attachment
> inside\nSystem.getProperties()------->"+System.getProperties());
>
> Session session = Session.getInstance(properties,null);
> Message message=new MimeMessage(session);
>
> message.setFrom(new InternetAddress("[EMAIL PROTECTED]"));
> message.setRecipient(Message.RecipientType.TO,new
> InternetAddress("[EMAIL PROTECTED]"));
> message.setSubject(filename);
>
> //Text part
> BodyPart bodyPart1=new MimeBodyPart();
> bodyPart1.setText("i sat in the chair\r\n and like to read news
> paper ");
> //file part
> BodyPart bodyPart2=new MimeBodyPart();
> FileDataSource fileDataSource=new
> FileDataSource("/usr/local/weblogic/myserver/public_html/index.html");
> bodyPart2.setDataHandler(new DataHandler(fileDataSource));
> bodyPart2.setFileName(fileDataSource.getName());
>
> Multipart multipart = new MimeMultipart();
> multipart.addBodyPart(bodyPart1);
> multipart.addBodyPart(bodyPart2);
>
> message.setContent(multipart);
>
> message.saveChanges();
> Transport.send(message);
> message.writeTo(System.out);
> }
>}
>
>************************************************************
>For adding multiple users there you can use this code, where, recipient is
>an array.
>
>************************************************************
>InternetAddress[] addressTo = new InternetAddress[recipients.length] ;
> for (int i = 0; i < recipients.length; i++)
> {
> addressTo[i] = new InternetAddress(recipients[i]);
> }
>
>
>
>
>hope this helps and I want few more comments for formatting the mail.
>Smita
>
>
>-------------------------------------------------
>This mail sent through : http://mail.sify.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://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets