package myBean.mail;

import javax.mail.*;  
import javax.mail.internet.*;  
import java.util.*;
import java.rmi.*;
import javax.activation.*;
import java.io.*;

public class Mail {
	
	private String froms="";
	private String recipients="";
	private String subject;
	private Message msg;
	
	public Mail(Message msg) {
		this.msg = msg;
		try {
			Address []addr = msg.getFrom();
			for(int i=0; i<addr.length; i++) {
				froms += addr[i].toString();
				if(i!=addr.length-1)
					froms += ",";
			}
			
			addr = msg.getAllRecipients();
			for(int i=0; i<addr.length; i++) {
				recipients += addr[i].toString();
				if(i!=addr.length-1)
					recipients += ",";
			}
			subject = msg.getSubject();
		
		}catch(MessagingException e){
			System.out.println("myBean.Mail" + e.getMessage());
		}
	}
	
	public String getSubject() {
		return subject;
	}
	
	public String getFroms() {
		return froms;
	}
	
	public String getRecipients() {
		return recipients;
	}
}