Search in sources :

Example 66 with MailerResult

use of org.olat.core.util.mail.MailerResult in project openolat by klemens.

the class IQEditReplaceWizard method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == mailCtr && event == Event.DONE_EVENT) {
        MailTemplate mailTemplate = mailCtr.getMailTemplate();
        if (mailTemplate != null) {
            MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
            String metaId = UUID.randomUUID().toString().replace("-", "");
            MailerResult result = new MailerResult();
            MailBundle[] bundles = mailManager.makeMailBundles(context, learners, mailTemplate, getIdentity(), metaId, result);
            result.append(mailManager.sendMessage(bundles));
            if (mailTemplate.getCpfrom()) {
                MailBundle ccBundle = mailManager.makeMailBundle(context, getIdentity(), mailTemplate, getIdentity(), metaId, result);
                result.append(mailManager.sendMessage(ccBundle));
            }
        }
        fireEvent(ureq, Event.DONE_EVENT);
    } else if (source == searchCtr && event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        doStep2(ureq);
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) MailBundle(org.olat.core.util.mail.MailBundle)

Example 67 with MailerResult

use of org.olat.core.util.mail.MailerResult in project openolat by klemens.

the class BGEmailCompositionStepController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    boolean success = false;
    try {
        File[] attachments = contactForm.getAttachments();
        MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
        MailBundle bundle = new MailBundle();
        bundle.setContext(context);
        bundle.setFromId(getIdentity());
        bundle.setContactLists(contactForm.getEmailToContactLists());
        bundle.setContent(contactForm.getSubject(), contactForm.getBody(), attachments);
        MailerResult result = mailService.sendMessage(bundle);
        success = result.isSuccessful();
        if (contactForm.isTcpFrom()) {
            MailBundle ccBundle = new MailBundle();
            ccBundle.setContext(context);
            ccBundle.setFromId(getIdentity());
            ccBundle.setCc(getIdentity());
            ccBundle.setContent(contactForm.getSubject(), contactForm.getBody(), attachments);
            MailerResult ccResult = mailService.sendMessage(ccBundle);
            success = ccResult.isSuccessful();
        }
    } catch (Exception e) {
        logError(null, e);
    }
    if (success) {
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) MailBundle(org.olat.core.util.mail.MailBundle) File(java.io.File)

Example 68 with MailerResult

use of org.olat.core.util.mail.MailerResult in project openolat by klemens.

the class SendDocumentsByEMailController method sendEmail.

protected void sendEmail(List<Identity> tos, String subject, String body, UserRequest ureq) {
    File[] attachmentArray = null;
    if (attachments != null && !attachments.isEmpty() && allowAttachments) {
        attachmentArray = attachments.toArray(new File[attachments.size()]);
    }
    MailerResult result = new MailerResult();
    String metaId = UUID.randomUUID().toString().replace("-", "");
    for (Identity to : tos) {
        MailBundle bundle = new MailBundle();
        bundle.setToId(to);
        bundle.setMetaId(metaId);
        bundle.setFromId(ureq.getIdentity());
        bundle.setContent(subject, body, attachmentArray);
        result.append(mailManager.sendMessage(bundle));
    }
    MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
}
Also used : MailerResult(org.olat.core.util.mail.MailerResult) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle) File(java.io.File)

Example 69 with MailerResult

use of org.olat.core.util.mail.MailerResult in project openolat by klemens.

the class MailManagerImpl method forwardToRealInbox.

@Override
public MailerResult forwardToRealInbox(Identity identity, DBMail mail, MailerResult result) {
    if (result == null) {
        result = new MailerResult();
    }
    List<DBMailAttachment> attachments = getAttachments(mail);
    Address to = createAddress(identity, result, true);
    MimeMessage message = createForwardMimeMessage(to, to, mail.getSubject(), mail.getBody(), attachments, result);
    if (message != null) {
        sendMessage(message, result);
    }
    return result;
}
Also used : DBMailAttachment(org.olat.core.util.mail.model.DBMailAttachment) InternetAddress(javax.mail.internet.InternetAddress) Address(javax.mail.Address) MailerResult(org.olat.core.util.mail.MailerResult) MimeMessage(javax.mail.internet.MimeMessage)

Example 70 with MailerResult

use of org.olat.core.util.mail.MailerResult in project openolat by klemens.

the class CourseRuntimeController method doLeave.

private void doLeave(UserRequest ureq) {
    if (roles.isGuestOnly())
        return;
    MailerResult result = new MailerResult();
    MailPackage reMailing = new MailPackage(result, getWindowControl().getBusinessControl().getAsString(), true);
    // leave course
    LeavingStatusList status = new LeavingStatusList();
    repositoryManager.leave(getIdentity(), getRepositoryEntry(), status, reMailing);
    // leave groups
    businessGroupService.leave(getIdentity(), getRepositoryEntry(), status, reMailing);
    if (status.isWarningManagedGroup() || status.isWarningManagedCourse()) {
        showWarning("sign.out.warning.managed");
    } else if (status.isWarningGroupWithMultipleResources()) {
        showWarning("sign.out.warning.mutiple.resources");
    } else {
        showInfo("sign.out.success", new String[] { getRepositoryEntry().getDisplayname() });
    }
    doClose(ureq);
}
Also used : LeavingStatusList(org.olat.repository.LeavingStatusList) MailPackage(org.olat.core.util.mail.MailPackage) MailerResult(org.olat.core.util.mail.MailerResult)

Aggregations

MailerResult (org.olat.core.util.mail.MailerResult)140 MailBundle (org.olat.core.util.mail.MailBundle)100 Identity (org.olat.core.id.Identity)82 MailContext (org.olat.core.util.mail.MailContext)66 MailContextImpl (org.olat.core.util.mail.MailContextImpl)66 MailTemplate (org.olat.core.util.mail.MailTemplate)46 Test (org.junit.Test)26 File (java.io.File)24 ArrayList (java.util.ArrayList)20 ContactList (org.olat.core.util.mail.ContactList)20 Locale (java.util.Locale)16 Translator (org.olat.core.gui.translator.Translator)16 VelocityContext (org.apache.velocity.VelocityContext)14 DBMailLight (org.olat.core.util.mail.model.DBMailLight)14 Date (java.util.Date)12 MailPackage (org.olat.core.util.mail.MailPackage)12 List (java.util.List)8 User (org.olat.core.id.User)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 Property (org.olat.properties.Property)7