//设置收件人地址
InternetAddress[] address = {new InternetAddress([email protected]),
new InternetAddress([email protected]),...};
msg.setRecipients(Message.RecipientType.TO, address);

解决方案 »

  1.   

    搞不定,
    InternetAddress[] address = {new InternetAddress([email protected]),
    new InternetAddress([email protected]),...};
    编译不过。
      

  2.   

    void setSendTo(String[] to) throws Exception{
          for (int i=0;i<to.length;i++)
             setSendTo(to[i]);
       }
       void setSendTo(String to) throws Exception{
    //            System.out.println("sending mail to :"+to[i]);
          InternetAddress[] address = {new InternetAddress(to)};
          msg.setRecipients(Message.RecipientType.TO, address);
       }
      

  3.   

    public Sendmail(String to, String from, String subject, String body) throws Exception{
          this();
          this.setSendTo(to);
          this.setFrom(from);
          this.setSubject(subject);
          this.setBody(body);
       }
       public Sendmail(String[] to, String from, String subject, String body) throws Exception{
          this();
          this.setSendTo(to);
          this.setFrom(from);
          this.setSubject(subject);
          this.setBody(body);
       }