當前位置: 首頁>>代碼示例>>Java>>正文


Java Email.addCc方法代碼示例

本文整理匯總了Java中org.apache.commons.mail.Email.addCc方法的典型用法代碼示例。如果您正苦於以下問題:Java Email.addCc方法的具體用法?Java Email.addCc怎麽用?Java Email.addCc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.mail.Email的用法示例。


在下文中一共展示了Email.addCc方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addEmailCc

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
private static void addEmailCc(Email message, String address) {
    try {
        message.addCc(address);
    } catch (EmailException e1) {
        LOGGER.error("Error adding email address {}", address);
    }
}
 
開發者ID:CROW-NDOV,項目名稱:displaydirect,代碼行數:8,代碼來源:EmailUtil.java

示例2: addCc

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
protected void addCc(Email email, String cc) {
    String[] ccs = splitAndTrim(cc);
    if (ccs != null) {
        for (String c : ccs) {
            try {
                email.addCc(c);
            } catch (EmailException e) {
                throw new FlowableException("Could not add " + c + " as cc recipient", e);
            }
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:13,代碼來源:MailActivityBehavior.java

示例3: addCc

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
protected void addCc(Email email, String cc) {
    String[] ccs = splitAndTrim(cc);
    if (ccs != null) {
        for (String c : ccs) {
            try {
                email.addCc(c);
            } catch (EmailException e) {
                throw new ActivitiException("Could not add " + c + " as cc recipient", e);
            }
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:13,代碼來源:MailActivityBehavior.java

示例4: initializeEmail

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
private void initializeEmail(final Email email) throws EmailException {
	email.setSocketConnectionTimeout(configuration.getInt("email.connection.timeout", Defaults.SOCKET_CONNECTION_TIMEOUT));
	email.setSocketTimeout(configuration.getInt("email.socket.timeout", Defaults.SOCKET_TIMEOUT));
	email.setStartTLSEnabled(configuration.getBoolean("email.starttls.enabled", Defaults.STARTTLS_ENABLED));
	email.setStartTLSRequired(configuration.getBoolean("email.starttls.required", Defaults.STARTTLS_REQUIRED));
	email.setSSLCheckServerIdentity(configuration.getBoolean("email.ssl.identity", Defaults.SSL_IDENTITY));
	email.setSSLOnConnect(configuration.getBoolean("email.ssl.connect", Defaults.SSL_CONNECT));
	email.setSmtpPort(configuration.getInt("email.port", Defaults.PORT));
	email.setSslSmtpPort(Integer.toString(configuration.getInt("email.ssl.port", Defaults.SSL_PORT)));

	email.setHostName(configuration.getString(CFG_KEY_EMAIL_HOST));

	// Authentication
	if (!configuration.getString(CFG_KEY_EMAIL_USERNAME, true).isEmpty() && !configuration.getString(CFG_KEY_EMAIL_PASSWORD, true).isEmpty()) {
		email.setAuthenticator(new DefaultAuthenticator(configuration.getString(CFG_KEY_EMAIL_USERNAME), configuration.getString(CFG_KEY_EMAIL_PASSWORD)));
	}

	// Sender
	if (configuration.getString(CFG_KEY_EMAIL_FROM_NAME, true).isEmpty()) {
		email.setFrom(configuration.getString(CFG_KEY_EMAIL_FROM_ADDRESS));
	}
	else {
		email.setFrom(configuration.getString(CFG_KEY_EMAIL_FROM_ADDRESS), configuration.getString(CFG_KEY_EMAIL_FROM_NAME));
	}

	// Recipients
	if (!configuration.getString(CFG_KEY_EMAIL_TO_ADDRESSES, true).isEmpty()) {
		email.addTo(configuration.getString(CFG_KEY_EMAIL_TO_ADDRESSES).split(EMAIL_ADDRESSES_SPLIT_REGEX));
	}
	if (!configuration.getString(CFG_KEY_EMAIL_CC_ADDRESSES, true).isEmpty()) {
		email.addCc(configuration.getString(CFG_KEY_EMAIL_CC_ADDRESSES).split(EMAIL_ADDRESSES_SPLIT_REGEX));
	}
	if (!configuration.getString(CFG_KEY_EMAIL_BCC_ADDRESSES, true).isEmpty()) {
		email.addBcc(configuration.getString(CFG_KEY_EMAIL_BCC_ADDRESSES).split(EMAIL_ADDRESSES_SPLIT_REGEX));
	}
}
 
開發者ID:Albertus82,項目名稱:RouterLogger,代碼行數:37,代碼來源:EmailSender.java

示例5: addCc

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
protected void addCc(Email email, String cc) {
  String[] ccs = splitAndTrim(cc);
  if (ccs != null) {
    for (String c : ccs) {
      try {
        email.addCc(c);
      } catch (EmailException e) {
        throw new ActivitiException("Could not add " + c + " as cc recipient", e);
      }
    }
  }
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:13,代碼來源:MailActivityBehavior.java

示例6: sendSimpleEmail

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
private void sendSimpleEmail() throws MangooMailerException {
    Config config = Application.getInstance(Config.class);
    try {
        Email email = new SimpleEmail();
        email.setCharset(Default.ENCODING.toString());
        email.setHostName(config.getSmtpHost());
        email.setSmtpPort(config.getSmtpPort());
        email.setAuthenticator(getDefaultAuthenticator());
        email.setSSLOnConnect(config.isSmtpSSL());
        email.setFrom(this.from);
        email.setSubject(this.subject);
        email.setMsg(render());
        
        for (String recipient : this.recipients) {
            email.addTo(recipient);
        }
        
        for (String cc : this.ccRecipients) {
            email.addCc(cc);
        }
        
        for (String bcc : this.bccRecipients) {
            email.addBcc(bcc);
        }
        
        email.send();
    } catch (EmailException | MangooTemplateEngineException e) {
        throw new MangooMailerException(e);
    }        
}
 
開發者ID:svenkubiak,項目名稱:mangooio,代碼行數:31,代碼來源:Mail.java

示例7: addCc

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
protected void addCc(Email email, String cc) {
  String[] ccs = splitAndTrim(cc);
  if (ccs != null) {
    for (String c : ccs) {
      try {
        email.addCc(c);
      } catch (EmailException e) {
        throw LOG.addCcException(c, e);
      }
    }
  }
}
 
開發者ID:camunda,項目名稱:camunda-bpm-platform,代碼行數:13,代碼來源:MailActivityBehavior.java

示例8: sendsimpleEmail2

import org.apache.commons.mail.Email; //導入方法依賴的package包/類
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!");

}
 
開發者ID:h819,項目名稱:spring-boot,代碼行數:64,代碼來源:SendEmaiWithGmail.java


注:本文中的org.apache.commons.mail.Email.addCc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。