Example usage for org.springframework.mail SimpleMailMessage getText

List of usage examples for org.springframework.mail SimpleMailMessage getText

Introduction

In this page you can find the example usage for org.springframework.mail SimpleMailMessage getText.

Prototype

@Nullable
    public String getText() 

Source Link

Usage

From source file:siia.booking.integration.StubMailSender.java

public void send(SimpleMailMessage message) throws MailException {
    this.lastMessageText = message.getText();
    counter.incrementAndGet();//from   www.  j av a 2  s .c  o  m
}

From source file:ar.com.zauber.commons.spring.mail.AbstractMailSender.java

/** Creates a text representation for simpleMessages */
public static String toString(final SimpleMailMessage[] simpleMessages) {
    final StringBuilder sb = new StringBuilder();
    sb.append("This window show that the system tried to send an email.\n").append('\n')
            .append("The email wasnt sent. To do change the AppContext.\n");

    for (final SimpleMailMessage message : simpleMessages) {

        sb.append(" --------------8<--------------\n");

        if (message.getFrom() != null) {
            sb.append("From: ").append(message.getFrom());
        }/*from w  ww.j a  v  a  2  s  .com*/
        if (message.getTo() != null) {
            sb.append("\nTo: ").append(Arrays.asList(message.getTo()));
        }
        if (message.getCc() != null) {
            sb.append("\nCc: ").append(Arrays.asList(message.getCc()));
        }
        if (message.getBcc() != null) {
            sb.append("\nBcc: ").append(Arrays.asList(message.getBcc()));
        }
        if (message.getReplyTo() != null) {
            sb.append("\nReply-To: ").append(message.getReplyTo());
        }
        if (message.getSentDate() != null) {
            sb.append("\nDate: ").append(message.getSentDate());
        }
        if (message.getSubject() != null) {
            sb.append("\nSubject: ").append(message.getSubject());
        }

        sb.append("\n\n").append(message.getText());
    }
    return sb.toString();
}

From source file:cs544.wamp_blog_engine.service.impl.NotificationService.java

@Override
public void contactAdmin(User user, String message) {
    SimpleMailMessage template = getToAdminTemplate();
    String emailMessage = String.format(template.getText(), message,
            user.getFirstname() + " " + user.getLastname());
    sendMail(user.getEmail(), template.getFrom(), template.getSubject(), emailMessage);
}

From source file:com.oak_yoga_studio.service.impl.NotificationServiceImpl.java

/**
 * Contact administrator//from ww  w  .ja v  a 2 s. c o  m
 * @param faculty
 * @param message 
 */
@Override
public void contactAdmin(Faculty faculty, String message) {
    SimpleMailMessage template = getToAdminTemplate();
    String emailMessage = String.format(template.getText(),
            faculty.getFirstName() + " " + faculty.getLastName(), message);
    sendMail(template.getFrom(), faculty.getEmail(), template.getSubject(), emailMessage);

}

From source file:com.oak_yoga_studio.service.impl.NotificationServiceImpl.java

/**
 * Begin email sending implementation, notify advisor
 * @param faculty/*from  ww  w.  j  a v a  2 s.  co m*/
 * @param message 
 */

@Override
public void notifyAdvisor(Faculty faculty, String message) {

    SimpleMailMessage template = getToAdvisorTemplate();
    String emailMessage = String.format(template.getText(), message,
            faculty.getFirstName() + " " + faculty.getLastName());
    sendMail(faculty.getEmail(), template.getFrom(), template.getSubject(), emailMessage);

}

From source file:com.oak_yoga_studio.service.impl.NotificationServiceImpl.java

/**
 * Notify customer/* w ww  .  j  a  v  a 2s.c o  m*/
 * @param customer
 * @param message
 */
@Override
public void notifyCustomer(Customer customer, String message) {
    SimpleMailMessage template = getToCustomersTemplate();
    String emailMessage = String.format(template.getText(),
            customer.getFirstName() + " " + customer.getLastName(), message);
    sendMail(template.getFrom(), customer.getEmail(), template.getSubject(), emailMessage);

}

From source file:cs544.wamp_blog_engine.service.impl.NotificationService.java

@Override
public void notifyBlogger(List<User> users, String message) {
    SimpleMailMessage template = getFromAdminTemplate();
    for (User user : users) {
        String emailMessage = String.format(template.getText(), user.getFirstname() + " " + user.getLastname(),
                message);/*from   ww w  . j  a  v a2  s  .c  om*/
        sendMail(template.getFrom(), user.getEmail(), template.getSubject(), emailMessage);
    }
}

From source file:cs544.wamp_blog_engine.service.impl.NotificationService.java

@Override
public void notifyFollowers(List<User> followers, Post post) {
    SimpleMailMessage template = getToFollowersTemplate();
    for (User user : followers) {
        String message = String.format(template.getText(), user.getFirstname() + " " + user.getLastname(),
                post.getTitle(), "Blog Title", post.getCreation_time());
        sendMail(template.getFrom(), user.getEmail(), template.getSubject(), message);
    }/*from  ww w  .j  a  v a  2s .c o  m*/
}

From source file:org.smigo.config.DevelopmentConfiguration.java

@Bean
public JavaMailSenderImpl javaMailSender() {
    return new JavaMailSenderImpl() {
        @Override//w  w  w  . j a v  a  2s. co m
        public String getDefaultEncoding() {
            return "UTF-8";
        }

        @Override
        public void send(SimpleMailMessage simpleMessage) throws MailException {
            try {
                //Thread.sleep(2000);
                String text = simpleMessage.getText();
                String subject = simpleMessage.getSubject();
                FileUtils.writeStringToFile(MAIL_FILE, text, Charset.defaultCharset());
                FileUtils.writeStringToFile(MAIL_FILE_TXT, subject + System.lineSeparator() + text,
                        Charset.defaultCharset());
            } catch (Exception e) {
                throw new MailSendException("Error sending email to " + simpleMessage.getFrom(), e);
            }
        }

        @Override
        public void send(MimeMessage mimeMessage) throws MailException {
            try {
                final String s = IOUtils.toString(mimeMessage.getInputStream());
                FileUtils.writeStringToFile(MAIL_FILE, s, Charset.defaultCharset());
            } catch (IOException | MessagingException e) {
                throw new MailSendException("Error sending email: " + mimeMessage.toString(), e);
            }
        }

        @Override
        public void send(SimpleMailMessage[] simpleMessages) throws MailException {
            throw new MailPreparationException("Method not supported");
        }
    };
}

From source file:com.oak_yoga_studio.service.impl.NotificationServiceImpl.java

/**
 * Notify all Faculties by administrator
 * @param faculties// w  w  w.j  a  va2s.c  om
 * @param message 
 */
@Override
public void notifyFaculties(List<Faculty> faculties, String message) {

    SimpleMailMessage template = getToFacultiesTemplate();
    for (Faculty faculty : faculties) {
        String emailMessage = String.format(template.getText(),
                faculty.getFirstName() + " " + faculty.getLastName(), message);
        sendMail(template.getFrom(), faculty.getEmail(), template.getSubject(), emailMessage);
    }

}