Search in sources :

Example 1 with BodyMailMessage

use of org.kuali.kfs.sys.mail.BodyMailMessage in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImpl method sendPayeeACHAccountAddOrUpdateEmail.

/**
 * Sends an ACH Account add/update notification email to the given payee.
 *
 * @param achAccount The Payee ACH Account that was added or updated.
 * @param payee The person affected by the change.
 * @param emailSubject The email subject line.
 * @param emailBody The email body; may contain "[propertyName]"-style placeholders to substitute in ACH Account values, as well as newlines.
 */
protected void sendPayeeACHAccountAddOrUpdateEmail(PayeeACHAccount achAccount, Person payee, String emailSubject, String emailBody) {
    if (StringUtils.isBlank(payee.getEmailAddressUnmasked())) {
        LOG.warn("Payee " + payee.getPrincipalName() + " has no email address defined in KFS. No notification emails will be sent for this user.");
        return;
    }
    // Construct mail message, and replace property placeholders and literal "\n" strings in the email body accordingly.
    BodyMailMessage message = new BodyMailMessage();
    message.setFromAddress(parameterService.getParameterValueAsString(KFSConstants.CoreModuleNamespaces.PDP, KfsParameterConstants.BATCH_COMPONENT, KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM));
    message.setSubject(emailSubject);
    message.setMessage(getResolvedEmailBody(achAccount, emailBody));
    message.addToAddress(payee.getEmailAddressUnmasked());
    // Send the message.
    emailService.sendMessage(message, false);
}
Also used : BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Example 2 with BodyMailMessage

use of org.kuali.kfs.sys.mail.BodyMailMessage in project cu-kfs by CU-CommunityApps.

the class CuPaymentFileServiceImpl method sendInactiveVendorsMessage.

/**
 * Sends notification emails when a PDP XML file has one or more inactive vendors.
 *
 * @param customer The customer's profile.
 * @param messageText The text to use as the body of the email message.
 */
private void sendInactiveVendorsMessage(CustomerProfile customer, String messageText) {
    BodyMailMessage message = new BodyMailMessage();
    message.setFromAddress(parameterService.getParameterValueAsString(KFSConstants.CoreModuleNamespaces.PDP, KfsParameterConstants.BATCH_COMPONENT, KFSConstants.FROM_EMAIL_ADDRESS_PARAM_NM));
    message.setSubject("Inactive vendors detected in PDP feed for customer: " + customer.getCustomerDescription());
    message.setMessage(messageText);
    // Send to pre-determined recipient list, plus the customer's process email address.
    message.setToAddresses(new HashSet<String>(parameterService.getParameterValuesAsString(KFSConstants.CoreModuleNamespaces.PDP, KfsParameterConstants.BATCH_COMPONENT, CUPdpParameterConstants.WARNING_INACTIVE_VENDOR_TO_EMAIL_ADDRESSES)));
    message.addToAddress(customer.getProcessingEmailAddr());
    emailService.sendMessage(message, false);
}
Also used : BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Example 3 with BodyMailMessage

use of org.kuali.kfs.sys.mail.BodyMailMessage in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountDocumentServiceImpl method sendPayeeACHAccountAddOrUpdateEmail.

protected void sendPayeeACHAccountAddOrUpdateEmail(PayeeACHAccount achAccount, Person payee, String emailSubject, String emailBody) {
    if (StringUtils.isBlank(payee.getEmailAddressUnmasked())) {
        LOG.warn("Payee " + payee.getPrincipalName() + " has no email address defined in KFS. No notification emails will be sent for this user.");
        return;
    }
    // Construct mail message, and replace property placeholders and literal "\n" strings in the email body accordingly.
    BodyMailMessage message = new BodyMailMessage();
    message.setFromAddress(parameterService.getParameterValueAsString(KFSConstants.CoreModuleNamespaces.PDP, KfsParameterConstants.BATCH_COMPONENT, KFSConstants.FROM_EMAIL_ADDRESS_PARAM_NM));
    message.setSubject(emailSubject);
    message.setMessage(getResolvedEmailBody(achAccount, emailBody));
    message.addToAddress(payee.getEmailAddressUnmasked());
    // Send the message.
    emailService.sendMessage(message, false);
}
Also used : BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Example 4 with BodyMailMessage

use of org.kuali.kfs.sys.mail.BodyMailMessage in project cu-kfs by CU-CommunityApps.

the class CuJobListener method notify.

protected void notify(JobExecutionContext jobExecutionContext, String jobStatus) {
    try {
        StringBuilder mailMessageSubject = new StringBuilder(jobExecutionContext.getJobDetail().getKey().getGroup()).append(": ").append(jobExecutionContext.getJobDetail().getKey().getName());
        BodyMailMessage mailMessage = new BodyMailMessage();
        mailMessage.setFromAddress(emailService.getDefaultFromAddress());
        if (jobExecutionContext.getMergedJobDataMap().containsKey(REQUESTOR_EMAIL_ADDRESS_KEY) && !StringUtils.isBlank(jobExecutionContext.getMergedJobDataMap().getString(REQUESTOR_EMAIL_ADDRESS_KEY))) {
            mailMessage.addToAddress(jobExecutionContext.getMergedJobDataMap().getString(REQUESTOR_EMAIL_ADDRESS_KEY));
        }
        if (SchedulerService.FAILED_JOB_STATUS_CODE.equals(jobStatus) || SchedulerService.CANCELLED_JOB_STATUS_CODE.equals(jobStatus)) {
            mailMessage.addToAddress(emailService.getDefaultToAddress());
        }
        String url = SpringContext.getBean(ParameterService.class).getParameterValueAsString("KFS-SYS", "Batch", "BATCH_REPORTS_URL");
        mailMessageSubject.append(": ").append(jobStatus);
        String messageText = MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.MESSAGE_BATCH_FILE_LOG_EMAIL_BODY), url);
        mailMessage.setMessage(messageText);
        if (mailMessage.getToAddresses().size() > 0) {
            mailMessage.setSubject(mailMessageSubject.toString());
            emailService.sendMessage(mailMessage, false);
        }
    } catch (Exception iae) {
        LOG.error("Caught exception while trying to send job completion notification e-mail for " + jobExecutionContext.getJobDetail().getKey().getName(), iae);
    }
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Example 5 with BodyMailMessage

use of org.kuali.kfs.sys.mail.BodyMailMessage in project cu-kfs by CU-CommunityApps.

the class ConcurReportEmailServiceImpl method sendEmail.

@Override
public void sendEmail(String subject, String body) {
    String toAddress = getConcurBatchUtilityService().getConcurParameterValue(ConcurParameterConstants.CONCUR_REPORT_EMAIL_TO_ADDRESS);
    String fromAddress = getConcurBatchUtilityService().getConcurParameterValue(ConcurParameterConstants.CONCUR_REPORT_EMAIL_FROM_ADDRESS);
    List<String> toAddressList = new ArrayList<>();
    toAddressList.add(toAddress);
    BodyMailMessage message = new BodyMailMessage();
    message.setFromAddress(fromAddress);
    message.setSubject(subject);
    message.getToAddresses().addAll(toAddressList);
    message.setMessage(body);
    boolean htmlMessage = false;
    if (LOG.isDebugEnabled()) {
        LOG.debug("sendEmail, from address: " + fromAddress + "  to address: " + toAddress);
        LOG.debug("sendEmail, the email subject: " + subject);
        LOG.debug("sendEmail, the email budy: " + body);
    }
    try {
        getEmailService().sendMessage(message, htmlMessage);
    } catch (Exception e) {
        LOG.error("sendEmail, the email could not be sent", e);
    }
}
Also used : ArrayList(java.util.ArrayList) BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Aggregations

BodyMailMessage (org.kuali.kfs.sys.mail.BodyMailMessage)19 ArrayList (java.util.ArrayList)3 LoadAchIncomeFileStep (edu.cornell.kfs.fp.batch.LoadAchIncomeFileStep)1 TemplateException (freemarker.template.TemplateException)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 AddressException (javax.mail.internet.AddressException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 CurrencyFormatter (org.kuali.kfs.core.web.format.CurrencyFormatter)1 DateFormatter (org.kuali.kfs.core.web.format.DateFormatter)1 Formatter (org.kuali.kfs.core.web.format.Formatter)1 IntegerFormatter (org.kuali.kfs.core.web.format.IntegerFormatter)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)1 Person (org.kuali.kfs.kim.api.identity.Person)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)1 EmailService (org.kuali.kfs.sys.service.EmailService)1