Java Code Examples for org.apache.commons.mail.Email#addBcc()

The following examples show how to use org.apache.commons.mail.Email#addBcc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MailActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addBcc(CommandContext commandContext, Email email, String bcc, String tenantId) {
    if (bcc == null) {
        return;
    }
    String newBcc = getForceTo(commandContext, tenantId);
    if (newBcc == null) {
        newBcc = bcc;
    }
    String[] bccs = splitAndTrim(newBcc);
    if (bccs != null) {
        for (String b : bccs) {
            try {
                email.addBcc(b);
            } catch (EmailException e) {
                throw new FlowableException("Could not add " + b + " as bcc recipient", e);
            }
        }
    }
}
 
Example 2
Source File: MailActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addBcc(Email email, String bcc, String tenantId) {
    if (bcc == null) {
        return;
    }
    String newBcc = getForceTo(tenantId);
    if (newBcc == null) {
        newBcc = bcc;
    }
    String[] bccs = splitAndTrim(newBcc);
    if (bccs != null) {
        for (String b : bccs) {
            try {
                email.addBcc(b);
            } catch (EmailException e) {
                throw new FlowableException("Could not add " + b + " as bcc recipient", e);
            }
        }
    }
}
 
Example 3
Source File: MailActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addBcc(Email email, String bcc) {
  String[] bccs = splitAndTrim(bcc);
  if (bccs != null) {
    for (String b : bccs) {
      try {
        email.addBcc(b);
      } catch (EmailException e) {
        throw new ActivitiException("Could not add " + b + " as bcc recipient", e);
      }
    }
  }
}
 
Example 4
Source File: MailActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addBcc(Email email, String bcc) {
  String[] bccs = splitAndTrim(bcc);
  if (bccs != null) {
    for (String b : bccs) {
      try {
        email.addBcc(b);
      } catch (EmailException e) {
        throw new ActivitiException("Could not add " + b + " as bcc recipient", e);
      }
    }
  }
}
 
Example 5
Source File: MailActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void addBcc(Email email, String bcc) {
    String[] bccs = splitAndTrim(bcc);
    if (bccs != null) {
        for (String b : bccs) {
            try {
                email.addBcc(b);
            } catch (EmailException e) {
                throw new ActivitiException("Could not add " + b + " as bcc recipient", e);
            }
        }
    }
}
 
Example 6
Source File: MailActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void addBcc(Email email, String bcc) {
  String[] bccs = splitAndTrim(bcc);
  if (bccs != null) {
    for (String b : bccs) {
      try {
        email.addBcc(b);
      } catch (EmailException e) {
        throw LOG.addBccException(b, e);
      }
    }
  }
}
 
Example 7
Source File: SendEmaiWithGmail.java    From spring-boot with Apache License 2.0 4 votes vote down vote up
public void sendsimpleEmail2(Email email, String userName, String password,
		String subject, String simpleEmailBody, String from, String to,
		String cc, String bcc) throws EmailException {

	// 创建SimpleEmail对象

	// 显示调试信息用于IED中输出
	email.setDebug(true);

	// 设置发送电子邮件的邮件服务器
	email.setHostName("smtp.gmail.com");

	// 邮件服务器是否使用ssl加密方式gmail就是,163就不是)
	email.setSSL(Boolean.TRUE);

	// 设置smtp端口号(需要查看邮件服务器的说明ssl加密之后端口号是不一样的)
	email.setSmtpPort(465);

	// 设置发送人的账号/密码
	email.setAuthentication(userName, password);

	// 显示的发信人地址,实际地址为gmail的地址
	email.setFrom(from);
	// 设置发件人的地址/称呼
	// email.setFrom("[email protected]", "发送人");

	// 收信人地址
	email.addTo(to);
	// 设置收件人的账号/称呼)
	// email.addTo("[email protected]", "收件人");

	// 多个抄送地址
	StrTokenizer stokenCC = new StrTokenizer(cc.trim(), ";");
	// 开始逐个抄送地址
	for (int i = 0; i < stokenCC.getTokenArray().length; i++) {
		email.addCc((String) stokenCC.getTokenArray()[i]);
	}

	// 多个密送送地址
	StrTokenizer stokenBCC = new StrTokenizer(bcc.trim(), ";");
	// 开始逐个抄送地址
	for (int i = 0; i < stokenBCC.getTokenArray().length; i++) {
		email.addBcc((String) stokenBCC.getTokenArray()[i]);
	}

	// Set the charset of the message.
	email.setCharset("UTF-8");

	email.setSentDate(new Date());

	// 设置标题,但是不能设置编码,commons 邮件的缺陷
	email.setSubject(subject);

	// 设置邮件正文
	email.setMsg(simpleEmailBody);

	// 就是send发送
	email.send();

	// 这个是我自己写的。
	System.out.println("The SimpleEmail send sucessful!");

}