import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
// Copyright (c) 2000 OOCL
public class MsgMultiSendSample extends Object {
  static String msgText1="hello !";  /**
   * Constructor
   */
  public MsgMultiSendSample() {
  }  /**
   * main
   * @param args
   */
  public static void main(String[] args) {
    //MsgMultiSendSample msgMultiSendSample = new MsgMultiSendSample();
    String to="[email protected]";
    String from="[email protected]";
    String host="202.101.25.211";    System.out.println("Pengda>>>>>>>>to, from and host set");    Properties props=new Properties();
    props.put("mail.smtp.host",host);    System.out.println("Pengda>>>>>>>>>>>>properties set");    Session session = Session.getDefaultInstance(props,null);    try{
      MimeMessage msg=new MimeMessage(session);
      msg.setFrom(new InternetAddress(from));
      InternetAddress[] address={new InternetAddress(to)};
      msg.setRecipients(Message.RecipientType.TO,address);
      msg.setSubject("Hello");
      msg.setSentDate(new Date());      MimeBodyPart mbp1=new MimeBodyPart();
      mbp1.setText(msgText1);      Multipart mp = new MimeMultipart();
      mp.addBodyPart(mbp1);      msg.setContent(mp);
      System.out.println("Pengda>>>>>>>>>>>about to send message....");
      Transport.send(msg);
      System.out.println("Pengda>>>>>>>>>>>Message sent");
    }catch(MessagingException mex){
      mex.printStackTrace();
      Exception ex = null;
      if((ex=mex.getNextException())!=null){
        ex.printStackTrace();
      }
    }
  }
}