当前位置: 首页>>代码示例>>Java>>正文


Java MimeMessageHelper.setCc方法代码示例

本文整理汇总了Java中org.springframework.mail.javamail.MimeMessageHelper.setCc方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMessageHelper.setCc方法的具体用法?Java MimeMessageHelper.setCc怎么用?Java MimeMessageHelper.setCc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mail.javamail.MimeMessageHelper的用法示例。


在下文中一共展示了MimeMessageHelper.setCc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMailWithTemplate

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:26,代码来源:MailServiceImpl.java

示例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);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:MailPlugin.java

示例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;
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:22,代码来源:AsyncMailSenderImpl.java

示例4: sendHtmlEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public int sendHtmlEmail(String subject, String content, String to) {

        try {
            MimeMessage mimeMessage = mailSender.createMimeMessage();
            MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "utf-8");
            mimeMessage.setContent(content, "text/html;charset=utf-8");
            messageHelper.setFrom(mailMessage.getFrom());
            messageHelper.setSubject(subject); //主题
            messageHelper.setTo(to); //发送给
            messageHelper.setCc(mailMessage.getFrom()); //抄送

            mailSender.send(mimeMessage);    //发送邮件

        } catch (Exception e) {
            logger.error("the email send error ! content: {}, exception: {}", content, e);
            return -1;
        }finally {
        }
        return 1;
    }
 
开发者ID:shuaijunlan,项目名称:Autumn-Framework,代码行数:21,代码来源:WebEmail.java

示例5: send

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void send(String subject, String content) {

        try {
            MimeMessage mimeMessage = mailSender.createMimeMessage();
            MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "utf-8");
            mimeMessage.setContent(content, "text/html;charset=utf-8");
            messageHelper.setFrom(mailMessage.getFrom());
            messageHelper.setSubject(subject); //主题
            messageHelper.setTo(mailMessage.getTo()); //发送给
            messageHelper.setCc(mailMessage.getFrom()); //抄送

            mailSender.send(mimeMessage);    //发送邮件

        } catch (Exception e) {
            logger.error("the email send error! content: {}, exception: {}", content, e);
        }
    }
 
开发者ID:shuaijunlan,项目名称:Autumn-Framework,代码行数:18,代码来源:WebEmail.java

示例6: 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);
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:18,代码来源:MailPlugin.java

示例7: 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;
	}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:25,代码来源:CommunicationManager.java

示例8: sendMailWithTemplate

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
public void sendMailWithTemplate(final TemplateMailTO mailParameters) throws MailException {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);

            message.setTo(mailParameters.getToMailAddress());
            message.setFrom(mailParameters.getFromMailAddress());
            message.setSubject(mailParameters.getSubject());
            if (mailParameters.hasCcMailAddress()) {
                message.setCc(mailParameters.getCcMailAddress());
            }
            if (mailParameters.hasReplyTo()) {
                message.setReplyTo(mailParameters.getReplyTo());
            }
            String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, mailParameters.getTemplateLocation(), mailParameters.getTemplateProperties());
            log.debug("*** TEST text='" + text + "'");
            message.setText(text, true);
            message.setValidateAddresses(true);

        }
    };
    this.mailSender.send(preparator);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:24,代码来源:MailServiceImpl.java

示例9: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
/**
 * 
 * @param toEmailAddress
 * @param ccEmailAdress
 * @param emailSubject
 * @param emailHtmlBodyText
 */
public void sendEmail(final String toEmailAddress,
					  final String ccEmailAdress,
   					  final String emailSubject,
   					  final String emailHtmlBodyText) {
   	
   	MimeMessagePreparator preparator = new MimeMessagePreparator() {
			public void prepare(MimeMessage mimeMessage) throws Exception {
   			MimeMessageHelper message = new MimeMessageHelper(mimeMessage);    			
   			message.setTo(toEmailAddress);
   			message.setCc(ccEmailAdress);
   			message.setSubject(emailSubject);
   			message.setText(emailHtmlBodyText, true);
   		}
   	};
   	mailSender.send(preparator);
   }
 
开发者ID:JD-Software,项目名称:JDeSurvey,代码行数:24,代码来源:MailService.java

示例10: sendTplEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendTplEmail(final String from, final List<String> to, final List<String> cc,
                         final String subject, final String tpl, final Map<String, Object> model) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(to.toArray(new String[to.size()]));
            message.setCc(cc.toArray(new String[cc.size()]));
            message.setFrom(from);
            message.setSubject(subject);
            VelocityContext context = new VelocityContext(model);
            StringWriter w = new StringWriter();
            Velocity.evaluate(context, w, "emailString", tpl);
            message.setText(w.toString(), true);
        }
    };
    JavaMailSenderImpl javaMailSenderImpl = (JavaMailSenderImpl) mailSender;
    javaMailSenderImpl.send(preparator);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:MailServiceImpl.java

示例11: sendTplLocationEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendTplLocationEmail(final String from, final List<String> to,
                                 final List<String> cc, final String subject, final String tplLocation,
                                 final Map<String, Object> model) {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
            message.setTo(to.toArray(new String[to.size()]));
            message.setCc(cc.toArray(new String[cc.size()]));
            message.setFrom(from);
            message.setSubject(subject);
            String tpl;
            tpl = VelocityEngineUtils.mergeTemplateIntoString(
                    velocityEngine, tplLocation, "utf-8", model);
            message.setText(tpl, true);
        }
    };
    JavaMailSenderImpl javaMailSenderImpl = (JavaMailSenderImpl) mailSender;
    javaMailSenderImpl.send(preparator);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:21,代码来源:MailServiceImpl.java

示例12: 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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:44,代码来源:CommunicationsManager.java

示例13: sendVelocityTemplateMailWithoutAttachment

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendVelocityTemplateMailWithoutAttachment(final String fromAddress, final List<String> toAddress, final List<String> ccAddress, final String subject,
                                                       final Map<String, Object> modelForMailContent, final String templateName, final boolean isTemplateHtml) throws Exception {
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
            helper.setSubject(subject);
            helper.setFrom(fromAddress);
            helper.setTo(toAddress.toArray(new String[toAddress.size()]));

            if (ccAddress != null && ccAddress.size() > 0) {
                helper.setCc(ccAddress.toArray(new String[ccAddress.size()]));
            }

            String text = geVelocityTemplateContent(modelForMailContent, templateName);
            log.debug("Template Name :" + templateName + "Template content : " + text);

            // use the true flag to indicate you need a multipart message
            helper.setText(text, isTemplateHtml);
        }
    };
    try {
        mailSender.send(preparator);
        log.debug("Template Mail without attachment successfully sent !! \nFrom Addres: " + fromAddress + " To Address: " + toAddress + " CC Address: " + ccAddress + "\n Subject: " + subject);
        log.debug(subject);
    } catch (MailException ex) {
        log.error("Error Sending Velocity Template mail: " + ex.getMessage());
        log.error("Sending mail failed for \nFrom Addres: " + fromAddress + " To Address: " + toAddress + " CC Address: " + ccAddress + "\n Subject: " + subject + " Template Name: " + templateName + " isTemplateHtml: " + isTemplateHtml);
        throw new Exception("Error Sending Velocity Template mail. " + ex.getMessage(), ex);
    }
}
 
开发者ID:Mahidharmullapudi,项目名称:timesheet-upload,代码行数:32,代码来源:EmailServiceImpl.java

示例14: sendMimeMailWithoutAttachment

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
@Override
public void sendMimeMailWithoutAttachment(final String fromAddress, final List<String> toAddress, final List<String> ccAddress, final String subject,
                                          final String mailContent, final boolean isMailHtml) throws Exception {

    MimeMessagePreparator preparator = new MimeMessagePreparator() {
        @Override
        public void prepare(MimeMessage mimeMessage) throws Exception {
            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
            helper.setSubject(subject);
            helper.setFrom(fromAddress);
            helper.setTo(toAddress.toArray(new String[toAddress.size()]));

            if (ccAddress != null && ccAddress.size() > 0) {
                helper.setCc(ccAddress.toArray(new String[ccAddress.size()]));
            }

            // use the true flag to indicate you need a multipart message
            helper.setText(mailContent, isMailHtml);
        }
    };
    try {
        mailSender.send(preparator);
        log.debug("EMail without attachment successfully sent !! \nFrom Addres: " + fromAddress + " To Address: " + toAddress + " CC Address: " + ccAddress + "\n Subject: " + subject);
        log.debug(subject);
    } catch (MailException ex) {
        log.error("Error Sending email: " + ex.getMessage());
        log.error("Sending mail failed for \nFrom Addres: " + fromAddress + " To Address: " + toAddress + " CC Address: " + ccAddress + "\n Subject: " + subject + " Content: " + mailContent + " isTemplateHtml: " + isMailHtml);
        throw new Exception("Error Sending Velocity Template mail. " + ex.getMessage(), ex);
    }

}
 
开发者ID:Mahidharmullapudi,项目名称:timesheet-upload,代码行数:32,代码来源:EmailServiceImpl.java

示例15: 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());
	}
}
 
开发者ID:juliuskrah,项目名称:quartz-manager,代码行数:28,代码来源:EmailJob.java


注:本文中的org.springframework.mail.javamail.MimeMessageHelper.setCc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。