Package org.springframework.mail.javamail

Examples of org.springframework.mail.javamail.MimeMessageHelper


    throws MessagingException {
        MimeMessage message =
            ((JavaMailSenderImpl) mailSender).createMimeMessage();

        // use the true flag to indicate you need a multipart message
        MimeMessageHelper helper = new MimeMessageHelper(message, true);

        helper.setTo(emailAddresses);
        helper.setText(bodyText);
        helper.setSubject(subject);

        helper.addAttachment(attachmentName, resource);

        ((JavaMailSenderImpl) mailSender).send(message);
    }
View Full Code Here


                    if (StringUtils.isNotBlank(smtpPassword)) {
                        sender.setPassword(smtpPassword);
                    }

                    MimeMessage message = sender.createMimeMessage();
                    MimeMessageHelper helper = new MimeMessageHelper(message, true);
                    helper.setTo(to);
                    helper.setFrom(task.getSender());
                    helper.setSubject(task.getSubject());
                    helper.setText(task.getTextBody(), task.getHtmlBody());

                    sender.send(message);

                    execution.setStatus(Status.SENT.name());
View Full Code Here

            }

            for (String to : task.getRecipients()) {
                try {
                    MimeMessage message = mailSender.createMimeMessage();
                    MimeMessageHelper helper = new MimeMessageHelper(message, true);
                    helper.setTo(to);
                    helper.setFrom(task.getSender());
                    helper.setSubject(task.getSubject());
                    helper.setText(task.getTextBody(), task.getHtmlBody());

                    mailSender.send(message);

                    execution.setStatus(Status.SENT.name());
View Full Code Here

     * @param invitation {@link InvitationBean}
     */
    public void sendEmailJoinInvitation(final String email, final String username) {
        final MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setTo(email);
              message.setSubject(buildSubject(getMessageProperties("mail.message.join.us.subject")));
              message.setFrom(noEmailResponse);
              @SuppressWarnings("rawtypes")
              Map model = new HashMap();
              getLogo(model);
              model.put("domain", domainDefault);
              model.put("username", username);
              getGreetingMessage(model);
              final String text = VelocityEngineUtils.mergeTemplateIntoString(
                 velocityEngine, "/org/encuestame/business/mail/templates/invite-enme.vm", "utf-8", model);
              message.setText(text, true);
           }
        };
        send(preparator);
     }
View Full Code Here

     * @param invitation {@link InvitationBean}
     */
    public void sendEmailInvitation(final InvitationBean invitation) {
        final MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setTo(invitation.getEmail());
              message.setSubject(buildSubject(getMessageProperties("email.messages.new.confirmation")));
              message.setFrom(noEmailResponse);
              @SuppressWarnings("rawtypes")
              Map model = new HashMap();
              getLogo(model);

              model.put("invitation", invitation);
              model.put("domain", domainDefault);
              model.put("username", "MyUsername");
              model.put("presentationMessage", getMessageProperties("mail.message.default.user.presentation", buildCurrentLocale(), null));
              model.put("subscribeMessage", getMessageProperties("mail.message.subscribe", buildCurrentLocale(), null));
              model.put("unSubscribeMessage", getMessageProperties("mail.message.unsubscribe", buildCurrentLocale(), null));
              getGreetingMessage(model);
              final String text = VelocityEngineUtils.mergeTemplateIntoString(
                 velocityEngine, "/org/encuestame/business/mail/templates/invitation.vm", "utf-8", model);
              message.setText(text, true);
           }
        };
        send(preparator);
     }
View Full Code Here

     */
    @Deprecated
    public void sendEmailNotification(final NotificationBean notification) {
        MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setTo(notification.getEmail());
              message.setSubject(buildSubject("New Password Confirmation"));
              message.setFrom(noEmailResponse);
              Map model = new HashMap();
              model.put("notification", notification);
              String text = VelocityEngineUtils.mergeTemplateIntoString(
                 velocityEngine, "/org/encuestame/business/mail/templates/notification.vm", model);
              message.setText(text, true);
           }
        };
        send(preparator);
     }
View Full Code Here

    * Sent a email after system startup.
    */
    public void sendStartUpNotification( final String startupMessage) throws MailSendException{
        MimeMessagePreparator preparator = new MimeMessagePreparator() {
            public void prepare(MimeMessage mimeMessage) throws Exception {
               MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
               message.setTo(EnMePlaceHolderConfigurer
                       .getProperty("setup.email.notification.webmaster"));
               message.setSubject(buildSubject(
                       getMessageProperties("mail.message.startup", buildCurrentLocale(), null)));
               message.setFrom(noEmailResponse);
               final Map model = new HashMap();
               model.put("message", startupMessage);
               String text = VelocityEngineUtils.mergeTemplateIntoString(
                  velocityEngine, "/org/encuestame/business/mail/templates/startup.vm", model);
               message.setText(text, true);
            }
         };
         send(preparator);
    }
View Full Code Here

     * @param user
     */
    public void sendPasswordConfirmationEmail(final SignUpBean user) {
        MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              final MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              log.debug("sendPasswordConfirmationEmail account to " + user.getEmail());
              message.setTo(user.getEmail());
              message.setSubject(buildSubject(getMessageProperties("email.password.remember.confirmation")));
              message.setFrom(noEmailResponse);
              final Map<String, Object> model = new HashMap<String, Object>();
              // build anomymous the salute
              final String _fullName = user.getUsername();
              final StringBuffer salute = new StringBuffer(getMessageProperties("mail.message.default.user.presentation",
                      buildCurrentLocale(),
                      null));
              salute.append(" ");
              salute.append("<b>");
              salute.append(_fullName);
              salute.append("</b>");
              user.setFullName(salute.toString());
              getLogo(model);
              model.put("user", user);
              model.put("password", user.getPassword());
              model.put("domain", domainDefault);
              model.put("passwordMessage", getMessageProperties("mail.message.password.passwordMessage", buildCurrentLocale(), null));
              model.put("passwordIntroMessage", getMessageProperties("mail.message.password.passwordIntroMessage", buildCurrentLocale(), null));
              model.put("signInMessage", getMessageProperties("mail.message.signInMessage", buildCurrentLocale(), null));
              getGreetingMessage(model);
              // create the template
              final String text = VelocityEngineUtils.mergeTemplateIntoString(
                              velocityEngine, "/org/encuestame/business/mail/templates/password-confirmation.vm",
                              model);
              message.setText(text, Boolean.TRUE);

           }
        };
        send(preparator);
     }
View Full Code Here

    public void sendConfirmYourAccountEmail(
            final SignUpBean user,
            final String inviteCode) {
        final MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              final MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              log.debug("confirm account to " + user.getEmail());
              message.setTo(user.getEmail());
              message.setSubject(buildSubject(
                      getMessageProperties("email.message.confirmation.message",
                      buildCurrentLocale(),
                      null)));
              message.setFrom(noEmailResponse);
              final Map<String, Object> model = new HashMap<String, Object>();
              if (user.getFullName() == null) {
                  // build
                  user.setFullName(getMessageProperties("mail.message.default.user.full.presentation",
                          buildCurrentLocale(),
                          null));
              } else {
                  // build anomymous the salute
                  final String _fullName = user.getFullName();
                  final StringBuffer salute = new StringBuffer(getMessageProperties("mail.message.default.user.presentation",
                          buildCurrentLocale(),
                          null));
                  salute.append(" ");
                  salute.append(_fullName);
                  user.setFullName(salute.toString());
              }
              getLogo(model);
              model.put("user", user);
              model.put("inviteCode", inviteCode);
              model.put("domain", domainDefault);
              model.put("successMessage", getMessageProperties("mail.message.registration.success", buildCurrentLocale(), null));
              model.put("confirmMessage", getMessageProperties("mail.message.confirm.please", buildCurrentLocale(), null));
              model.put("confirmMessageSubfooter", getMessageProperties("mail.message.confirm.subfooter", buildCurrentLocale(), null));
              getGreetingMessage(model);
              // create the template
              final String text = VelocityEngineUtils.mergeTemplateIntoString(
                              velocityEngine, "/org/encuestame/business/mail/templates/confirm-your-account.vm",
                              model);
              message.setText(text, Boolean.TRUE);
           }
        };
        send(preparator);
     }
View Full Code Here

     * @param message
     */
    public void welcomeNotificationAccount(final UserAccount user) {
        MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              final String _fullName = user.getCompleteName();
              final StringBuffer salute = new StringBuffer(getMessageProperties("mail.message.default.user.presentation",
                      buildCurrentLocale(),
                      null));
              salute.append(" ");
              salute.append(_fullName);
              user.setCompleteName(salute.toString());
              message.setTo(user.getUserEmail());
              message.setSubject(buildSubject(getMessageProperties("mail.message.welcome.message.subject", buildCurrentLocale(), null)));
              message.setFrom(noEmailResponse);
              Map model = new HashMap();
              getLogo(model);
              model.put("domain", domainDefault);
              model.put("user", user);
              final String[] properties = {EnMePlaceHolderConfigurer.getProperty("mail.message.app.name")};
              model.put("welcomeMessage", getMessageProperties("mail.message.welcome.message.description", buildCurrentLocale(), null));
              model.put("enjoyMessage", getMessageProperties("mail.message.welcome.message.enjoyMessage", buildCurrentLocale(), null));
              getGreetingMessage(model);
              String text = VelocityEngineUtils.mergeTemplateIntoString(
                 velocityEngine, "/org/encuestame/business/mail/templates/welcome-account.vm", model);
              message.setText(text, true);
           }
        };
        send(preparator);
     }
View Full Code Here

TOP

Related Classes of org.springframework.mail.javamail.MimeMessageHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.