Search in sources :

Example 1 with EmailInfo

use of com.haulmont.cuba.core.global.EmailInfo in project cuba by cuba-platform.

the class ExceptionReportServiceBean method sendExceptionReport.

@Override
public void sendExceptionReport(String supportEmail, Map<String, Object> binding) {
    try {
        Map<String, Object> map = new HashMap<>(binding);
        User user = userSessionSource.getUserSession().getUser();
        map.put("user", user);
        map.put("toHtml", new MethodClosure(HtmlUtils.class, "convertToHtml"));
        String body = getExceptionReportBody(map);
        String subject = getExceptionReportSubject(map);
        EmailInfo info = EmailInfoBuilder.create().setAddresses(supportEmail).setCaption(subject).setBody(body).build();
        emailer.sendEmail(info);
    } catch (Exception e) {
        log.error("Error sending exception report", e);
        throw new RuntimeException("Error sending exception report");
    }
}
Also used : User(com.haulmont.cuba.security.entity.User) HashMap(java.util.HashMap) HtmlUtils(com.haulmont.bali.util.HtmlUtils) EmailInfo(com.haulmont.cuba.core.global.EmailInfo) MethodClosure(org.codehaus.groovy.runtime.MethodClosure) IOException(java.io.IOException)

Example 2 with EmailInfo

use of com.haulmont.cuba.core.global.EmailInfo in project cuba by cuba-platform.

the class EmailServiceBean method sendEmail.

@Override
public void sendEmail(String address, String caption, String body, String bodyContentType, EmailAttachment... attachment) throws EmailException {
    EmailInfo emailInfo = EmailInfoBuilder.create(address, caption, body).setBodyContentType(bodyContentType).setAttachments(attachment).build();
    emailer.sendEmail(emailInfo);
}
Also used : EmailInfo(com.haulmont.cuba.core.global.EmailInfo)

Aggregations

EmailInfo (com.haulmont.cuba.core.global.EmailInfo)2 HtmlUtils (com.haulmont.bali.util.HtmlUtils)1 User (com.haulmont.cuba.security.entity.User)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 MethodClosure (org.codehaus.groovy.runtime.MethodClosure)1