本文整理汇总了Java中org.springframework.mail.javamail.MimeMessageHelper.setBcc方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMessageHelper.setBcc方法的具体用法?Java MimeMessageHelper.setBcc怎么用?Java MimeMessageHelper.setBcc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mail.javamail.MimeMessageHelper
的用法示例。
在下文中一共展示了MimeMessageHelper.setBcc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareMessage
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private Optional<MimeMessageHelper> prepareMessage(Optional<MimeMessage> oMimeMessage,
String recipient, String subject, MailType emailType)
throws EmailNotPreparedException {
Optional<MimeMessageHelper> oMessage = Optional.empty();
try {
if (oMimeMessage.isPresent()) {
oMessage = Optional.ofNullable(new MimeMessageHelper(oMimeMessage.get(), true, "UTF-8"));
if (oMessage.isPresent()) {
MimeMessageHelper message = oMessage.get();
message.setSubject(subject);
message.setFrom(this.sendfrom);
message.setTo(recipient);
if ((this.enableBccToConfirmationEmail && emailType.equals(MailType.CONFIRMATION_EMAIL))
|| (this.enableBccToSummaryEmail && emailType.equals(MailType.SUMMARY_EMAIL))) {
message.setBcc(this.admin);
}
}
}
} catch (MessagingException e) {
LOG.error("Error building the message of email type {} to {}", emailType, recipient);
throw new EmailNotPreparedException(e);
}
return oMessage;
}
示例2: sendMail
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendMail(SendMailActionMsg msg) throws MessagingException {
log.debug("Sending mail {}", msg);
MimeMessage mailMsg = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mailMsg, "UTF-8");
helper.setFrom(msg.getFrom());
helper.setTo(msg.getTo());
if (!StringUtils.isEmpty(msg.getCc())) {
helper.setCc(msg.getCc());
}
if (!StringUtils.isEmpty(msg.getBcc())) {
helper.setBcc(msg.getBcc());
}
helper.setSubject(msg.getSubject());
helper.setText(msg.getBody());
mailSender.send(helper.getMimeMessage());
log.debug("Mail sent {}", msg);
}
示例3: prepareMessage
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private MimeMessage prepareMessage(final Email email) {
final MimeMessage message = javaMailSender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
try {
helper.setFrom(email.getSender());
helper.setTo(email.getRecipients());
helper.setSubject(email.getSubject());
helper.setText(email.getContent(), email.isHtml());
final String[] cc = email.getCc();
if (cc != null) {
helper.setCc(cc);
}
if (email.getBcc() != null) {
helper.setBcc(email.getBcc());
}
} catch (MessagingException e) {
log.warn("{}", e);
throw new IllegalArgumentException(e);
}
return message;
}
示例4: mailTo
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Async
public void mailTo(String[] targetuser,String title,String content,JavaMailSender javaMailSender) {//邮件功能
try {
MimeMessage mimeMsg = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMsg, false, "utf-8");
helper.setText(content, true);
helper.setBcc(targetuser);
helper.setSubject(title);
String authormail = (String) PropertyPlaceholder.getProperty("mail.sendfrom");
String authorname = (String) PropertyPlaceholder.getProperty("mail.sendname");
helper.setFrom(authormail,authorname);
javaMailSender.send(mimeMsg);
log.info("Mail send to "+Arrays.toString(targetuser));
} catch(Exception e) {
e.printStackTrace();
}
}
示例5: sendMail
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendMail(SendMailActionMsg msg) throws MessagingException {
log.debug("Sending mail {}", msg);
MimeMessage mailMsg = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mailMsg, "UTF-8");
helper.setFrom(msg.getFrom());
helper.setTo(msg.getTo());
if (!StringUtils.isEmpty(msg.getCc())) {
helper.setCc(msg.getCc());
}
if (!StringUtils.isEmpty(msg.getBcc())) {
helper.setBcc(msg.getBcc());
}
helper.setSubject(msg.getSubject());
helper.setText(msg.getBody());
mailSender.send(helper.getMimeMessage());
log.debug("Mail sent {}", msg);
}
示例6: mimeMessagePreparator
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public MimeMessagePreparator mimeMessagePreparator(final EmailData emailData,final ByteArrayOutputStream attachmentAsByteArrResource){
MimeMessagePreparator mailMsg = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper msgHelper = new MimeMessageHelper(mimeMessage, true);
msgHelper.setSubject(emailData.getSubject());
msgHelper.setTo(emailData.getTo().toArray(new String[emailData.getTo().size()]));
msgHelper.setCc(emailData.getCc().toArray(new String[emailData.getCc().size()]));
if(!CollectionUtils.isEmpty(emailData.getBcc())){
msgHelper.setBcc(emailData.getBcc().toArray(new String[emailData.getBcc().size()]));
}
msgHelper.setText(emailData.getBody(), true);
if (attachmentAsByteArrResource != null){
saveHtmlToPdf(emailData.getBody(), attachmentAsByteArrResource);
if(attachmentAsByteArrResource.size() > 0){
msgHelper.addAttachment("Ticket.pdf", new ByteArrayResource(attachmentAsByteArrResource.toByteArray()));
}
}
msgHelper.setFrom(emailData.getFrom());
}
};
return mailMsg;
}
示例7: sendContactNotification
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendContactNotification(final ContactForm contactForm) {
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@SuppressWarnings({ "rawtypes", "unchecked" })
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(configService.getValue("EMAIL_TO_CONTACT_MESSAGE"));
message.setBcc("[email protected]");
message.setFrom(new InternetAddress(contactForm.getEmail()));
message.setSubject("New contact message " + contactForm.getTopic());
message.setReplyTo(contactForm.getEmail());
message.setSentDate(new Date());
Map model = new HashMap();
model.put("newMessage", contactForm);
String text = VelocityEngineUtils.mergeTemplateIntoString(
velocityEngine, "velocity/newContactMessageToAdmin.vm", "UTF-8", model);
message.setText(text, true);
}
};
this.mailSender.send(preparator);
}
示例8: sendSuggestPodcastNotification
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendSuggestPodcastNotification(final SuggestedPodcast suggestedPodcast) {
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@SuppressWarnings({ "rawtypes", "unchecked" })
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(configService.getValue("EMAIL_TO_SUGGEST_PODCAST"));
message.setBcc("[email protected]");
message.setFrom(new InternetAddress(suggestedPodcast.getEmail()) );
message.setSubject("New suggested podcast");
message.setSentDate(new Date());
Map model = new HashMap();
model.put("newPodcast", suggestedPodcast);
String text = VelocityEngineUtils.mergeTemplateIntoString(
velocityEngine, "velocity/suggestPodcastNotificationMessage.vm", "UTF-8", model);
message.setText(text, true);
}
};
mailSender.send(preparator);
}
示例9: email
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
/**
* Email.
*
* @param text the text
* @param from the from
* @param subject the subject
* @param to the to
* @param cc the cc
* @param bcc the bcc
* @return the boolean
*/
public boolean email(final String text, final String from,
final String subject, final String to,
final String cc, final String bcc) {
try {
if (!isMailSenderDefined() || StringUtils.isBlank(text) || StringUtils.isBlank(from)
|| StringUtils.isBlank(subject) || StringUtils.isBlank(to)) {
LOGGER.warn("Could not send email to [{}] because either no address/subject/text is found or email settings are not configured.", to);
return false;
}
final MimeMessage message = this.mailSender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo(to);
helper.setText(text);
helper.setSubject(subject);
helper.setFrom(from);
helper.setPriority(1);
if (StringUtils.isNotBlank(cc)) {
helper.setCc(cc);
}
if (StringUtils.isNotBlank(bcc)) {
helper.setBcc(bcc);
}
this.mailSender.send(message);
return true;
} catch (final Exception ex) {
LOGGER.error(ex.getMessage(), ex);
}
return false;
}
示例10: sendEmail
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void sendEmail(JobDataMap map) {
String subject = map.getString("subject");
String messageBody = map.getString("messageBody");
List<String> to = (List<String>) map.get("to");
List<String> cc = (List<String>) map.get("cc");
List<String> bcc = (List<String>) map.get("bcc");
MimeMessage message = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(message, false);
for(String receipient : to) {
helper.setFrom("[email protected]", "Julius from Dynamic Quartz");
helper.setTo(receipient);
helper.setSubject(subject);
helper.setText(messageBody);
if(!isEmpty(cc))
helper.setCc(cc.stream().toArray(String[]::new));
if(!isEmpty(bcc))
helper.setBcc(bcc.stream().toArray(String[]::new));
mailSender.send(message);
}
} catch (MessagingException | UnsupportedEncodingException e) {
log.error("An error occurred: {}", e.getLocalizedMessage());
}
}
示例11: sendMail
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public boolean sendMail(EmailNotice emailNotice) {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message);
try {
helper.setSubject(emailNotice.getMhSubject());
helper.setText(emailNotice.getMailBody());
String[] addresses = convertEmpNoToMailAddress(emailNotice.getMhTo());
if (addresses.length == 0) {
LOG.warn("toが設定されていない、または該当ユーザーのメールアドレスが設定されていないため"
+ "メールを送信できません。email_notice.id = {}", emailNotice.getId());
return false;
}
helper.setBcc(addresses);
// String [] from = convertEmpNoToMailAddress(emailNotice.getMhFrom());
// if (from.length == 0) {
// LOG.warn("fromが設定されていない、または該当ユーザーのメールアドレスが設定されていないため"
// + "メールを送信できません。email_notice.id = {}", emailNotice.getId());
// return false;
// }
helper.setFrom(emailNotice.getMhFrom());
mailSender.send(message);
return true;
} catch (MessagingException e) {
LOG.warn("メール送信に失敗しました", e);
return false;
}
}
示例12: sendMessage
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendMessage(String userMail, String subject, String message, boolean html) {
MimeMessage mimeMessage = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false);
helper.setBcc(userMail);
helper.setSubject(subject);
helper.setText(message, html);
helper.setFrom(mailMessage.getFrom());
} catch (MessagingException e) {
e.printStackTrace();
}
this.mailSender.send(mimeMessage);
}
示例13: sendMessageWithAttachment
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendMessageWithAttachment(String userMail, String subject, String message, String filename, String attachment, boolean html){
MimeMessage mimeMessage = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setBcc(userMail);
helper.setSubject(subject);
helper.setText(message, html);
helper.setFrom(mailMessage.getFrom());
helper.addAttachment(filename, new ByteArrayResource(attachment.getBytes()));
} catch (MessagingException e) {
e.printStackTrace();
}
this.mailSender.send(mimeMessage);
}
示例14: sendBulkMessage
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendBulkMessage(String[] userMail, String subject, String message, boolean html) {
MimeMessage mimeMessage = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false);
helper.setBcc(userMail);
helper.setSubject(subject);
helper.setText(message, html);
helper.setFrom(mailMessage.getFrom());
} catch (MessagingException e) {
e.printStackTrace();
}
mailSender.send(mimeMessage);
}
示例15: send
import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public static void send(
String from, String to,
String cc[], String bcc[],
String fileNames[], File files[],
String subject, String text) throws MailException, Exception {
if (mailSender==null) {
throw new Exception("null mailSender!");
}
if (StringUtils.isBlank(from) || StringUtils.isBlank(to)) {
throw new Exception("from and to is required!");
}
if (fileNames!=null && files!=null) {
if (fileNames.length != files.length) {
throw new Exception("File parameter error!");
}
}
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true, Constants.BASE_ENCODING);
helper.setFrom(from);
helper.setTo( to.endsWith(";") ? to.substring(0, to.length()-1) : to );
helper.setSubject(subject);
helper.setText(text, true);
if (null!=cc && cc.length>0) {
helper.setCc(cc);
}
if (null!=bcc && bcc.length>0) {
helper.setBcc(bcc);
}
for (int i=0; fileNames!=null && i<fileNames.length; i++) {
helper.addAttachment(fileNames[i], files[i]);
}
mailSender.send(message);
}