Search in sources :

Example 1 with ListingMailConfiguration

use of eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration in project dwoss by gg-net.

the class SalesListingProducerOperation method prepareAndSend.

/**
 * Prepare and send filejackets to the specified email address.
 * <p>
 * @param fileJackets files to be send
 */
private void prepareAndSend(List<FileJacket> fileJackets) {
    SubMonitor m = monitorFactory.newSubMonitor("Transfer");
    m.message("sending Mail");
    m.start();
    try {
        ListingMailConfiguration config = listingService.get().listingMailConfiguration();
        MultiPartEmail email = mandator.prepareDirectMail();
        email.setFrom(config.getFromAddress());
        email.addTo(config.getToAddress());
        email.setSubject(config.getSubject());
        email.setMsg(config.toMessage());
        for (FileJacket fj : fileJackets) {
            email.attach(new javax.mail.util.ByteArrayDataSource(fj.getContent(), "application/xls"), fj.getHead() + fj.getSuffix(), "Die Händlerliste für die Marke ");
        }
        email.send();
        m.finish();
    } catch (EmailException e) {
        throw new RuntimeException(e);
    }
}
Also used : ListingMailConfiguration(eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration) java.util(java.util) eu.ggnet.dwoss.util(eu.ggnet.dwoss.util) MultiPartEmail(org.apache.commons.mail.MultiPartEmail) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) EmailException(org.apache.commons.mail.EmailException)

Aggregations

ListingMailConfiguration (eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration)1 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 eu.ggnet.dwoss.util (eu.ggnet.dwoss.util)1 java.util (java.util)1 EmailException (org.apache.commons.mail.EmailException)1 MultiPartEmail (org.apache.commons.mail.MultiPartEmail)1