Package org.springframework.mail.javamail

Examples of org.springframework.mail.javamail.MimeMessageHelper.addAttachment()


                     messageBody = buildMessageBody(info, props);
                 }
                 message.setText(messageBody, true);
                 for (Attachment attachment : info.getAttachments()) {
                     ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType());
                     message.addAttachment(attachment.getFilename(), dataSource);
                 }
             }
         };
         return preparator;
               
View Full Code Here


    }

    if ( hasAttachments ) {
      for (DataSource attachment : this.composeAttachments) {

        messageHelper.addAttachment( attachment.getName(), attachment );
      }

    }

    if ( !isRead() ) {
View Full Code Here

    }

    if ( hasAttachments ) {
      for (DataSource attachment : this.composeAttachments) {

        messageHelper.addAttachment( attachment.getName(), attachment );
      }

    }

    if ( !isRead() ) {
View Full Code Here

      String content = generateContent(userName);
      helper.setText(content, true);

      File attachment = generateAttachment();
      helper.addAttachment("mailAttachment.txt", attachment);

      mailSender.send(msg);
      logger.info("HTML版邮件已发送至springside3.demo@gmail.com");
    } catch (MessagingException e) {
      logger.error("构造邮件失败", e);
View Full Code Here

        messageHelper.setSubject(title);
        messageHelper.setText(text, isHtml);

        if (attachments != null) {
            for (Pair<String, InputStreamSource> pair : attachments) {
                messageHelper.addAttachment(pair.a, pair.b);
            }
        }

        mimeMessage = messageHelper.getMimeMessage();
        if (priority != null) {
View Full Code Here

          message.setTo( InternetAddress.parse( to ) );
          message.setSubject( subject );
          message.setText( body, false );

          for (File attachment : attachments)
            message.addAttachment( attachment.getName(), attachment );

          logger.debug("Sending email: {}", subject);
        }
      } );
    }
View Full Code Here

      String content = generateContent(userName);
      helper.setText(content, true);

      File attachment = generateAttachment();
      helper.addAttachment("mailAttachment.txt", attachment);

      mailSender.send(msg);
      logger.info("HTML版邮件已发送至springside3.demo@gmail.com");
    } catch (MessagingException e) {
      logger.error("构造邮件失败", e);
View Full Code Here

        }

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

        helper.addAttachment(attachmentName, resource);

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

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

        helper.addAttachment(attachmentName, resource);

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

                File file = null;
                for (int i = 0; i < fileNames.length; i++) {
                    fileName = fileNames[i];
                    file = files[i];
                    if (fileName != null && file != null) {
                        helper.addAttachment(fileName, file);
                    }
                }
            }
            transport.connect();
            transport.sendMessage(msg,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.