// loop through, getting each address as a String,
// add to a second ArrayList which gets set on the form bean
ArrayList toList = (ArrayList)message.getTo();
ArrayList formToList = new ArrayList();
for (int i = 0; i < toList.size(); i++) {
MailAddress ma = (MailAddress)toList.get(i);
formToList.add((String)ma.getAddress());
}
emailForm.set("toList", formToList);
// get all the Cc: addresses from the message
// loop through, getting each address as a String,
// add to a second ArrayList which gets set on the form bean
ArrayList ccList = (ArrayList)message.getCc();
ArrayList formCcList = new ArrayList();
for (int j = 0; j < ccList.size(); j++) {
MailAddress macc = (MailAddress)ccList.get(j);
formCcList.add((String)macc.getAddress());
}
emailForm.set("ccList", formCcList);
// set the From: field on the form bean
emailForm.set("from", message.getMailFrom());