here is the code u can just make some changes in that ..............
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Sendmail
{
public Sendmail()
{
}
public void postMail( String recipients[ ], String subject, String
message , String from) throws MessagingException
{
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", "64.4.50.7"); //"smtp.jcom.net");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length] ;
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.addHeader("MyHeaderName", "myHeaderValue");
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
public String getMessage(String str) throws FileNotFoundException,
IOException
{
String Message="";
DataInputStream in = new DataInputStream(new BufferedInputStream(new
FileInputStream(str)));
while(in.available() != 0)
Message += (char)in.readByte();
return Message;
}
public static void main(String[] args)
{
Sendmail sm = new Sendmail();
String [] s = {"[EMAIL PROTECTED]"};
String st = "";
try
{
BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter file name:");
st = stdin.readLine();
for ( int i = 0; i<=1; i++)
{
try
{
sm.postMail(s, "hi", sm.getMessage(st),
"[EMAIL PROTECTED]" );
}
catch(Exception e)
{
System.out.println(e);
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
-----Original Message-----
From: Smita Kotnis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 13, 2001 3:34 PM
To: [EMAIL PROTECTED]
Subject: CC field in Java Mail
hi all,
How to send a Java Mail to multiple users? Any code avialable with
some body?
Thanks in advance
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