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


Java SimpleMailMessage.setBcc方法代码示例

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


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

示例1: sendMailAsBcc

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * 指定された宛先一覧に BCC で一括送信します。
 *
 * @param recipients 宛先一覧
 * @param subject    件名
 * @param text       本文
 */
@Async
public void sendMailAsBcc(List<String> recipients, String subject, String text) {
    if (recipients.isEmpty()) {
        throw new IllegalArgumentException("recipients is empty.");
    }
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(recipients.toArray(new String[recipients.size()]));
    message.setSubject(subject);
    message.setText(text);
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:24,代码来源:MailService.java

示例2: sendAttendMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * 登録完了メールを送信します。
 *
 * @param membership  メンバー情報
 * @param convocation 対象のイベント招待
 */
@Async
void sendAttendMail(Membership membership, Convocation convocation) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【登録完了】" + convocation.getSubject());
    message.setText(membership.getName() + " さん\n\n" +
            convocation.getSubject() + "の登録が完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:26,代码来源:MailService.java

示例3: sendCancelMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * キャンセル完了メールを送信します。
 *
 * @param membership  メンバー情報
 * @param convocation 対象のイベント招待
 */
@Async
void sendCancelMail(Membership membership, Convocation convocation) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【キャンセル完了】" + convocation.getSubject());
    message.setText(membership.getName() + " さん\n\n" +
            convocation.getSubject() + "の登録キャンセルが完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:26,代码来源:MailService.java

示例4: sendUpdateMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * メンバー情報更新完了メールを送信します。
 *
 * @param membership メンバー情報
 */
@Async
void sendUpdateMail(Membership membership) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setReplyTo(appReply);
    message.setBcc(appReply);
    message.setTo(membership.getEmail());
    message.setSubject("【会員情報編集完了】Java研修 Go研修 OB・OG会");
    message.setText(membership.getName() + " さん\n\n" +
            "会員情報の編集が完了しました。\n\n" +
            "詳細の確認・登録内容の変更は以下 URL より行ってください。\n" +
            appUrl + "\n\n" +
            "本メールに関するお問合せ先: " + appReply + "\n" +
            "Java研修 Go研修 OB・OG会");
    try {
        mailSender.send(message);
    } catch (MailException e) {
        exceptionHandler.accept(e);
    }
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:25,代码来源:MailService.java

示例5: sendSimpleMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * 发送文本邮件  setCc 抄送 setBcc 密送
 */
@Async("mailAsync")
public void sendSimpleMail(String to, String subject, String content) {
	SimpleMailMessage message = new SimpleMailMessage();
	message.setFrom(from);
	message.setTo(to);
	message.setBcc(from);
	message.setSubject(subject);
	message.setText(content);
	message.setSentDate(new Date());
	try {
		mailSender.send(message);
		logger.info("简单邮件已经发送。");
	} catch (Exception e) {
		logger.error("发送简单邮件时发生异常!", e);
	}

}
 
开发者ID:CharleyXu,项目名称:tulingchat,代码行数:21,代码来源:MailUtil.java

示例6: send

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
@Override
public void send(MailMessage message) throws MailSenderException {
    SimpleMailMessage smm = new SimpleMailMessage();
    MailBody body = message.getBody();
    smm.setText(MailUtils.toPlainText(body));
    MailHead head = message.getHead();
    smm.setFrom(head.getFrom());
    smm.setReplyTo(head.getReplyTo());
    smm.setSubject(head.getSubject());
    smm.setTo(asArray(head.getTo()));
    smm.setCc(asArray(head.getCc()));
    smm.setBcc(asArray(head.getBcc()));
    smm.setSentDate(head.getSentDate());
    LOG.info("message to send {}", smm);
    mailSender.send(smm);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:17,代码来源:SpringMailSenderBackend.java

示例7: sendEmail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
    * Construct and a send simple email message from a Mail Message.
    * 
    * @param message
    *            the Mail Message
 * @throws MessagingException 
    */
@Override
      @SuppressWarnings("unchecked")
public void sendEmail(MailMessage message) throws MessagingException {
       
       // Construct a simple mail message from the Mail Message
       SimpleMailMessage smm = new SimpleMailMessage();
       smm.setTo( (String[])message.getToAddresses().toArray(new String[message.getToAddresses().size()]) );
       smm.setBcc( (String[])message.getBccAddresses().toArray(new String[message.getBccAddresses().size()]) );
       smm.setCc( (String[])message.getCcAddresses().toArray(new String[message.getCcAddresses().size()]) );
       smm.setSubject(message.getSubject());
       smm.setText(message.getMessage());
       smm.setFrom(message.getFromAddress());

       try {
       	if ( LOG.isDebugEnabled() ) {
       		LOG.debug( "sendEmail() - Sending message: " + smm.toString() );
       	}
           mailSender.send(smm);
       }
       catch (Exception e) {
       	LOG.error("sendEmail() - Error sending email.", e);
		throw new RuntimeException(e);
       }
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:32,代码来源:MailerImpl.java

示例8: sendPlainText

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
public static void sendPlainText(String to, String cc, String from, String subject, String text) {
    logger.info("sendPlainText");
    
    if (to.contains(",")) {
        to = to.replace(",", "");
    }
    if (to.contains(":")) {
        to = to.replace(":", "");
    }
            
    SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setTo(to);
    if (StringUtils.isNotBlank(cc)) {
        simpleMailMessage.setCc(cc);
    }
    simpleMailMessage.setBcc(ADMIN_EMAIL);
    simpleMailMessage.setFrom(from);
    simpleMailMessage.setSubject(subject);
    simpleMailMessage.setText(text);

    JavaMailSenderImpl javaMailSenderImpl = new JavaMailSenderImpl();
    String smtpHost = ConfigHelper.getProperty("smtp.host");
    javaMailSenderImpl.setHost(smtpHost);

    logger.info("Sending e-mail to " + simpleMailMessage.getTo()[0] + " with subject \"" + simpleMailMessage.getSubject() + "\"...");
    logger.info("Text: " + simpleMailMessage.getText());
    if (EnvironmentContextLoaderListener.env != Environment.DEV) {
        javaMailSenderImpl.send(simpleMailMessage);
    }
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:31,代码来源:Mailer.java

示例9: sendTextMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
@Override
public void sendTextMail(final MailMetaData mailMetaData, final String text) {
	if (suppressMail) {
		return;
	}
	final SimpleMailMessage mailMessage = new SimpleMailMessage();
	mailMessage.setFrom(new StringBuilder().append(mailMetaData.getFromName()).append(" <").append(mailMetaData.getFromAddress())
			.append(">").toString());
	mailMessage.setSubject(mailMetaData.getSubject());
	mailMessage.setReplyTo(mailMetaData.getReplyTo());
	if (mailMetaData.getCcAddresses() != null && mailMetaData.getCcAddresses().size() > 0) {
		mailMessage.setCc((String[]) mailMetaData.getCcAddresses().toArray(new String[mailMetaData.getCcAddresses().size()]));
	}
	if (mailMetaData.getBccAddresses() != null && mailMetaData.getBccAddresses().size() > 0) {
		mailMessage.setBcc((String[]) mailMetaData.getBccAddresses().toArray(new String[mailMetaData.getBccAddresses().size()]));
	}
	if (mailMetaData.getToAddresses() != null && mailMetaData.getToAddresses().size() > 0) {
		mailMessage.setTo((String[]) mailMetaData.getToAddresses().toArray(new String[mailMetaData.getToAddresses().size()]));
	}
	mailMessage.setText(text);
	try {
		mailSender.send(mailMessage);
	} catch (MailException e) {
		throw new SendMailException(new StringBuilder().append("Error sending mail: ").append(mailMetaData.toString()).toString(),
				e);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:28,代码来源:MailServiceImpl.java

示例10: sendTextMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
/**
 * API to send mail using javaMailSender.
 * 
 * @param mailMetaData
 * @param text
 * @throws WizardMailException
 */
private void sendTextMail(final MailMetaData mailMetaData, final String text) throws WizardMailException {
	LOGGER.info("Entering method sendTextMail....");
	final SimpleMailMessage mailMessage = new SimpleMailMessage();
	mailMessage.setFrom(new StringBuilder().append(mailMetaData.getFromName()).append(MailConstants.SPACE).append(
			MailConstants.LESS_SYMBOL).append(mailMetaData.getFromAddress()).append(MailConstants.GREATER_SYMBOL).toString());
	mailMessage.setSubject(mailMetaData.getSubject());
	mailMessage.setReplyTo(mailMetaData.getReplyTo());
	if (mailMetaData.getCcAddresses() != null && mailMetaData.getCcAddresses().size() > 0) {
		mailMessage.setCc((String[]) mailMetaData.getCcAddresses().toArray(new String[mailMetaData.getCcAddresses().size()]));
	}
	if (mailMetaData.getBccAddresses() != null && mailMetaData.getBccAddresses().size() > 0) {
		mailMessage.setBcc((String[]) mailMetaData.getBccAddresses().toArray(new String[mailMetaData.getBccAddresses().size()]));
	}
	if (mailMetaData.getToAddresses() != null && mailMetaData.getToAddresses().size() > 0) {
		mailMessage.setTo((String[]) mailMetaData.getToAddresses().toArray(new String[mailMetaData.getToAddresses().size()]));
	}
	mailMessage.setText(text);
	try {
		LOGGER.info("Sending mail using JavaMailSender....");
		wizardMailSender.send(mailMessage);
	} catch (MailException e) {
		LOGGER.error("Exception occured during sending Email.Email meta deta is " + mailMetaData.toString() + ".Excption is "
				+ e.getMessage(), e);
		throw new WizardMailException(new StringBuilder().append("Error sending mail: ").append(mailMetaData.toString())
				.toString(), e);
	}
	LOGGER.info("Mail sent successfully.Exiting method sendTextMail....");
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:36,代码来源:WizardMailServiceImpl.java

示例11: sendMail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
public void sendMail(String from, String to, String bcc, String subject, String body) {
     
    SimpleMailMessage message = new SimpleMailMessage();
      
    message.setFrom(from);
    message.setTo(to);
    if (bcc != null)
    message.setBcc(bcc);
    message.setSubject(subject);
    message.setText(body);
    mailSender.send(message);
     
}
 
开发者ID:bonprix,项目名称:solidsearch-bot,代码行数:14,代码来源:MailService.java

示例12: sendEmail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
public void sendEmail(String subject, 
		String emailBody, 
		String to, 
		String bcc, 
		String from, 
		String replyTo,
		String host){
	
	SimpleMailMessage mailMessage = new SimpleMailMessage();
	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
	mailSender.setHost(host);
	
	if(StringUtils.isNotBlank(to)){
		mailMessage.setTo(to);
	}
	if(StringUtils.isNotBlank(bcc)){
		mailMessage.setBcc(bcc);
	}
	
	if(StringUtils.isNotBlank(from)){
		mailMessage.setFrom(from);
	}
	
	if(StringUtils.isNotBlank(replyTo)){
		mailMessage.setReplyTo(replyTo);
	}
	
	if(StringUtils.isNotBlank(subject)){
		mailMessage.setSubject(subject);
	}
	
	mailMessage.setText(emailBody);
	mailSender.send(mailMessage);
	logger.info("Email Message has been sent..");
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:36,代码来源:EmailSenderAction.java

示例13: javaMailSenderWithSimpleMessage

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
@Test
public void javaMailSenderWithSimpleMessage() throws MessagingException, IOException {
	MockJavaMailSender sender = new MockJavaMailSender();
	sender.setHost("host");
	sender.setPort(30);
	sender.setUsername("username");
	sender.setPassword("password");

	SimpleMailMessage simpleMessage = new SimpleMailMessage();
	simpleMessage.setFrom("[email protected]");
	simpleMessage.setReplyTo("[email protected]");
	simpleMessage.setTo("[email protected]");
	simpleMessage.setCc(new String[] {"[email protected]", "[email protected]"});
	simpleMessage.setBcc(new String[] {"[email protected]", "[email protected]"});
	Date sentDate = new GregorianCalendar(2004, 1, 1).getTime();
	simpleMessage.setSentDate(sentDate);
	simpleMessage.setSubject("my subject");
	simpleMessage.setText("my text");
	sender.send(simpleMessage);

	assertEquals("host", sender.transport.getConnectedHost());
	assertEquals(30, sender.transport.getConnectedPort());
	assertEquals("username", sender.transport.getConnectedUsername());
	assertEquals("password", sender.transport.getConnectedPassword());
	assertTrue(sender.transport.isCloseCalled());

	assertEquals(1, sender.transport.getSentMessages().size());
	MimeMessage sentMessage = sender.transport.getSentMessage(0);
	List<Address> froms = Arrays.asList(sentMessage.getFrom());
	assertEquals(1, froms.size());
	assertEquals("[email protected]", ((InternetAddress) froms.get(0)).getAddress());
	List<Address> replyTos = Arrays.asList(sentMessage.getReplyTo());
	assertEquals("[email protected]", ((InternetAddress) replyTos.get(0)).getAddress());
	List<Address> tos = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.TO));
	assertEquals(1, tos.size());
	assertEquals("[email protected]", ((InternetAddress) tos.get(0)).getAddress());
	List<Address> ccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.CC));
	assertEquals(2, ccs.size());
	assertEquals("[email protected]", ((InternetAddress) ccs.get(0)).getAddress());
	assertEquals("[email protected]", ((InternetAddress) ccs.get(1)).getAddress());
	List<Address> bccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.BCC));
	assertEquals(2, bccs.size());
	assertEquals("[email protected]", ((InternetAddress) bccs.get(0)).getAddress());
	assertEquals("[email protected]", ((InternetAddress) bccs.get(1)).getAddress());
	assertEquals(sentDate.getTime(), sentMessage.getSentDate().getTime());
	assertEquals("my subject", sentMessage.getSubject());
	assertEquals("my text", sentMessage.getContent());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:49,代码来源:JavaMailSenderTests.java

示例14: sendSecureEmail

import org.springframework.mail.SimpleMailMessage; //导入方法依赖的package包/类
public void sendSecureEmail(String subject, 
		String emailBody, 
		String to, 
		String bcc, 
		String from, 
		String replyTo,
		String host,
		String password){
	
	SimpleMailMessage mailMessage = new SimpleMailMessage();
	JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
	
	mailSender.setHost(host);
	mailSender.setPort(587);
	mailSender.setProtocol("smtp");
	
	Properties props = new Properties();
	props.put("mail.smtp.starttls.enable","true");
	props.put("mail.smtp.auth", "true");
	
	mailSender.setJavaMailProperties(props);
	
	if(StringUtils.isNotBlank(to)){
		mailMessage.setTo(to);
	}
	if(StringUtils.isNotBlank(bcc)){
		mailMessage.setBcc(bcc);
	}
	
	if(StringUtils.isNotBlank(from)){
		mailMessage.setFrom(from);
		mailSender.setUsername(from);	
	}
	
	if(StringUtils.isNotBlank(password)){
		mailSender.setPassword(password);
	}
	
	if(StringUtils.isNotBlank(replyTo)){
		mailMessage.setReplyTo(replyTo);
	}
	
	if(StringUtils.isNotBlank(subject)){
		mailMessage.setSubject(subject);
	}
	
	mailMessage.setText(emailBody);
	mailSender.send(mailMessage);
	logger.info("Secure Email Message has been sent..");
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:51,代码来源:EmailSenderAction.java


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