use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class ContactForm method getEmailTo.
/**
* retrieve the contact list names from the to field, and map them back to the
* stored contact lists names.
*
* @return
*/
protected String getEmailTo() {
String retVal = "";
String value;
if (tto != null)
value = tto.getValue();
else
value = ttoBig.getValue();
String sep = "";
int i = 0;
int j = -1;
i = value.indexOf("[", j + 1);
j = value.indexOf("]", j + 2);
while (i > -1 && j > 0) {
String contactListName = value.substring(i + 1, j);
i = value.indexOf("[", j + 1);
j = value.indexOf("]", j + 2);
if (contactLists.containsKey(contactListName)) {
ContactList found = contactLists.get(contactListName);
retVal += sep + found.toString();
sep = ", ";
}
}
return retVal;
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class FinishCallback method sendMail.
private boolean sendMail(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
boolean success = false;
try {
ContactList contacts = new ContactList("Forum");
ListWrapper recipients = (ListWrapper) runContext.get(SendMailStepForm.RECIPIENTS);
contacts.addAllIdentites(recipients.getListOfIdentity());
MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
Identity sender = (Identity) runContext.get(SendMailStepForm.SENDER);
bundle.setFromId(sender != null ? sender : ureq.getIdentity());
bundle.setContactLists(new ArrayList<ContactList>(Arrays.asList(contacts)));
MailTemplate mailTemplate = (MailTemplate) runContext.get(SendMailStepForm.MAIL_TEMPLATE);
bundle.setContent(mailTemplate.getSubjectTemplate(), mailTemplate.getBodyTemplate());
MailerResult result = mailService.sendMessage(bundle);
return success = result.isSuccessful();
} catch (Exception e) {
log.error(null, e);
return success;
}
}
Aggregations