home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Mail For Me / Mail4ME.jar / de / trantor / mail / Envelope.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-10-21  |  2.4 KB  |  69 lines

  1. package de.trantor.mail;
  2.  
  3. import java.util.Vector;
  4.  
  5. public class Envelope {
  6.    private Message message;
  7.    private String sender;
  8.    private Vector recipients;
  9.  
  10.    public Envelope(Message message, boolean autofill) {
  11.       this.message = message;
  12.       this.recipients = new Vector();
  13.       if (autofill) {
  14.          this.sender = message.getHeaderValue("From");
  15.          String[] toFields = message.getAllHeaderValues("To");
  16.  
  17.          for(int i = 0; i < toFields.length; ++i) {
  18.             this.recipients.addElement(toFields[i]);
  19.          }
  20.  
  21.          String[] ccFields = message.getAllHeaderValues("CC");
  22.  
  23.          for(int i = 0; i < ccFields.length; ++i) {
  24.             this.recipients.addElement(ccFields[i]);
  25.          }
  26.  
  27.          String[] bccFields = message.getAllHeaderValues("Bcc");
  28.  
  29.          for(int i = 0; i < bccFields.length; ++i) {
  30.             this.recipients.addElement(bccFields[i]);
  31.          }
  32.       }
  33.  
  34.    }
  35.  
  36.    public Message getMessage() {
  37.       return this.message;
  38.    }
  39.  
  40.    public void setSender(String address) {
  41.       this.sender = address;
  42.    }
  43.  
  44.    public String getSender() {
  45.       return this.sender;
  46.    }
  47.  
  48.    public int addRecipient(String address) {
  49.       this.recipients.addElement(address);
  50.       return this.recipients.size() - 1;
  51.    }
  52.  
  53.    public void setRecipient(int index, String address) throws ArrayIndexOutOfBoundsException {
  54.       this.recipients.setElementAt(address, index);
  55.    }
  56.  
  57.    public int getRecipientCount() {
  58.       return this.recipients.size();
  59.    }
  60.  
  61.    public String getRecipient(int index) throws ArrayIndexOutOfBoundsException {
  62.       return (String)this.recipients.elementAt(index);
  63.    }
  64.  
  65.    public void removeRecipient(int index) throws ArrayIndexOutOfBoundsException {
  66.       this.recipients.removeElementAt(index);
  67.    }
  68. }
  69.