home *** CD-ROM | disk | FTP | other *** search
- package de.trantor.mail;
-
- import java.util.Vector;
-
- public class Envelope {
- private Message message;
- private String sender;
- private Vector recipients;
-
- public Envelope(Message message, boolean autofill) {
- this.message = message;
- this.recipients = new Vector();
- if (autofill) {
- this.sender = message.getHeaderValue("From");
- String[] toFields = message.getAllHeaderValues("To");
-
- for(int i = 0; i < toFields.length; ++i) {
- this.recipients.addElement(toFields[i]);
- }
-
- String[] ccFields = message.getAllHeaderValues("CC");
-
- for(int i = 0; i < ccFields.length; ++i) {
- this.recipients.addElement(ccFields[i]);
- }
-
- String[] bccFields = message.getAllHeaderValues("Bcc");
-
- for(int i = 0; i < bccFields.length; ++i) {
- this.recipients.addElement(bccFields[i]);
- }
- }
-
- }
-
- public Message getMessage() {
- return this.message;
- }
-
- public void setSender(String address) {
- this.sender = address;
- }
-
- public String getSender() {
- return this.sender;
- }
-
- public int addRecipient(String address) {
- this.recipients.addElement(address);
- return this.recipients.size() - 1;
- }
-
- public void setRecipient(int index, String address) throws ArrayIndexOutOfBoundsException {
- this.recipients.setElementAt(address, index);
- }
-
- public int getRecipientCount() {
- return this.recipients.size();
- }
-
- public String getRecipient(int index) throws ArrayIndexOutOfBoundsException {
- return (String)this.recipients.elementAt(index);
- }
-
- public void removeRecipient(int index) throws ArrayIndexOutOfBoundsException {
- this.recipients.removeElementAt(index);
- }
- }
-