Example usage for org.springframework.mail SimpleMailMessage setText

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

Introduction

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

Prototype

@Override
    public void setText(String text) 

Source Link

Usage

From source file:net.bluemix.questions.web.controllers.QuestionController.java

@RequestMapping(value = "{id}/reply", method = RequestMethod.POST)
public void reply(@PathVariable Long id, @RequestBody Reply reply) {
    Question q = repo.findOne(id);//www  .  j  av a 2 s. c  o  m
    q.setAnswered(true);
    repo.save(q);
    if (q.getEmail() != null) {
        SimpleMailMessage msg = new SimpleMailMessage();
        msg.setTo(q.getEmail());
        msg.setFrom("noreply@sessionquestions.ng.bluemix.net");
        msg.setSubject("Thanks For Submitting Your Question!");
        msg.setText(reply.getContent());
        mailSender.send(msg);
    }
    if (q.getNumber() != null) {
        Account acct = twilioClient.getAccount();
        SmsFactory smsFactory = acct.getSmsFactory();
        Map<String, String> params = new HashMap<String, String>();
        params.put(FROM, q.getSession().getNumber());
        params.put(TO, q.getNumber());
        params.put(BODY, reply.getContent());
        try {
            smsFactory.create(params);
        } catch (TwilioRestException e) {
            LOG.warn("Error sending SMS reply.", e);
        }
    }
}

From source file:com.example.controller.SendEmailController.java

@RequestMapping(method = RequestMethod.POST)
public String doSendEmail(HttpServletRequest request, Model model) throws ClassNotFoundException, SQLException {
    // takes input from e-mail form
    String recipientAddress = request.getParameter("email");
    String subject = "Email PartyChef";

    // prints debug info
    System.out.println("To: " + recipientAddress);

    // creates a simple e-mail object
    SimpleMailMessage email = new SimpleMailMessage();
    email.setTo(recipientAddress);/*from  w  w  w. j ava 2s  .c o m*/
    Users u = Database.getEmail(recipientAddress);
    if (u != null) {
        email.setFrom("none-reply@PartyChef.com");
        email.setSubject(subject);
        email.setText("PartyChef to : " + u.getName() + "\n\nUsername : " + u.getUsername() + "\n\n"
                + "Password : " + u.getPassword() + "\n\nBest regards,\nPartyChef team\n");
        // sends the e-mail
        /*com.google.apphosting.api.ApiProxy.Environment env = ApiProxy.getCurrentEnvironment();
                
        env.getAttributes().put("com.google.apphosting.api.ApiProxy.api_deadline_key", 9999 );*/
        mailSender.send(email);

        return "login";
    }

    // forwards to the view named "Result"
    model.addAttribute("error", "Email is invalid");
    return "EmailSend";
}

From source file:cherry.foundation.mail.SimpleMessageStore.java

@Override
public long createMessage(String launcherId, String messageName, LocalDateTime scheduledAt, String from,
        List<String> to, List<String> cc, List<String> bcc, String subject, String body) {

    long messageId = nextMessageId.getAndIncrement();

    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);//from   w ww .j a v a  2  s. c  o m
    message.setTo(toArray(to));
    message.setCc(toArray(cc));
    message.setBcc(toArray(bcc));
    message.setSubject(subject);
    message.setText(body);

    MessageRecord record = new MessageRecord();
    record.setScheduledAt(scheduledAt);
    record.setSimpleMailMessage(message);
    messageRecordMap.put(messageId, record);

    return messageId;
}

From source file:com.logsniffer.event.publisher.MailPublisher.java

@Override
public void publish(final Event event) throws PublishException {
    try {//from   ww  w. j  a  va2  s.  co  m
        final VelocityContext context = velocityRenderer.getContext(event);
        final SimpleMailMessage email = new SimpleMailMessage();
        email.setFrom(getFrom());
        email.setSubject(velocityRenderer.render(getSubject(), context));
        email.setText(velocityRenderer.render(getTextMessage(), context) + " ");
        final String to2 = getTo();
        email.setTo(to2.split(",|\\s"));
        mailSender.send(email);
        logger.info("Sent event notification to: {}", to2);
    } catch (final MailException e) {
        throw new PublishException("Failed to send event notification to mail: " + getTo(), e);
    }
}

From source file:com.admob.rocksteady.reactor.Email.java

/**
 * Handle the triggered event//from   www . j  ava 2  s . c  o m
 *
 * @param newEvents the new events in the window
 * @param oldEvents the old events in the window
 */
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
    if (newEvents == null) {
        return;
    }
    for (EventBean newEvent : newEvents) {
        try {
            String name = newEvent.get("name").toString();
            String value = newEvent.get("value").toString();
            String colo = newEvent.get("colo").toString();

            SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);

            msg.setTo(this.recipient);

            logger.info(" event triggered - type " + type + " - " + colo + " - " + name + " - " + value);
            msg.setText(" event triggered - type " + type + " - " + colo + " - " + name + " - " + value);

            // this.mailSender.send(msg);

        } catch (Exception e) {
            logger.error("Problem with event: " + newEvent.toString());
        }

    }
}

From source file:org.smigo.user.MailHandler.java

@PreDestroy
public void sendShutdownAdminNotification() {
    final SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setTo(notifierEmail);
    simpleMailMessage.setFrom(mailSenderUsername);
    simpleMailMessage.setSubject("[SMIGO] Server");
    simpleMailMessage.setText("Server shutdown");
    mailSender.send(simpleMailMessage);//from  ww w  . j  av a  2s. c  o  m
}

From source file:org.smigo.user.MailHandler.java

public void sendClientMessage(String emailAddress, String subject, String text) {
    final SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setTo(emailAddress);
    simpleMailMessage.setFrom(mailSenderUsername);
    simpleMailMessage.setSubject("Smigo " + subject);
    simpleMailMessage.setText(text);
    senderExecutor.execute(() -> mailSender.send(simpleMailMessage));
}

From source file:org.smigo.user.MailHandler.java

public void sendAdminNotification(String subject, Object text) {
    final SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setTo(notifierEmail);
    simpleMailMessage.setFrom(mailSenderUsername);
    simpleMailMessage.setSubject("[SMIGO] " + subject);
    simpleMailMessage.setText(text.toString());
    senderExecutor.execute(() -> mailSender.send(simpleMailMessage));
}

From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java

/**
 * Send a confirmation email of a valid day report.
 * Includes xml readable string of it./*from www. j  a va2s  . com*/
 * @see org.springframework.mail.SimpleMailMessage
 * @see org.springframework.mail.javamail.JavaMailSenderImpl
 */
@Override
public void placeReply(Reply reply) throws Exception {

    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setTo(reply.getEmailAddress());
    msg.setReplyTo(reply.getEmailAddress());
    msg.setFrom(user);
    msg.setSubject("RE: " + (reply.getSubject() == null ? "" : reply.getSubject()));
    msg.setText("This is an automated email. Do not reply.\n" + "Your day report is recieved and saved ."
            + " You are allowed to make modifications till 23:59 GMT+3."
            + " Just send new report, the old one will be deleted.\n" + "Converted report look like:\n"
            + reply.getXml());

    try {
        this.mailSender.send(msg);
    } catch (MailException ex) {
        logger.error(ex.getMessage());
    }
}

From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java

/**
 * Send an error email of a not valid day report.
 * /*  w  w  w. j a v  a  2 s .  c o m*/
 * @see org.springframework.mail.SimpleMailMessage
 * @see org.springframework.mail.javamail.JavaMailSenderImpl
 * @param dayReport I used DayReport as a parameter to know whom to send
 */
public void sendError(DayReport dayReport) {
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setTo(dayReport.getPersonId());
    msg.setReplyTo(dayReport.getPersonId());
    msg.setFrom(user);
    msg.setSubject("RE: " + (dayReport.getSubject() == null ? "" : dayReport.getSubject()));
    msg.setText("This is an automated email. Do not reply.\n"
            + "No valid reports were detected. Check your report.\nExample of valid reports:\n"
            + "helping Google with Android, in process, 7\nmain job/ in process/1\nnothing actually. done. 3\n");

    try {
        this.mailSender.send(msg);
    } catch (MailException ex) {
        logger.error(ex.getMessage());
    }
}