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


Java HtmlEmail.addCc方法代碼示例

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


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

示例1: doSend

import org.apache.commons.mail.HtmlEmail; //導入方法依賴的package包/類
private void doSend(String recipient, String sender, Set<String> cc, String subject, String content,
                    EmailAttachment... attachments) throws EmailException {
    HtmlEmail email = new HtmlEmail();
    email.setCharset("utf-8");
    for (EmailAttachment attachment : attachments) {
        email.attach(attachment);
    }
    email.setHostName(HOST);
    email.setSmtpPort(PORT);
    email.setAuthenticator(new DefaultAuthenticator(USER, PWD));
    email.setSSLOnConnect(USE_SSL);
    email.setSubject(subject);
    email.addTo(recipient);
    email.setFrom(String.format("Exam <%s>", SYSTEM_ACCOUNT));
    email.addReplyTo(sender);
    for (String addr : cc) {
        email.addCc(addr);
    }
    email.setHtmlMsg(content);
    if (USE_MOCK) {
        mockSending(email, content, attachments);
    } else {
        email.send();
    }
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:26,代碼來源:EmailSenderImpl.java

示例2: test

import org.apache.commons.mail.HtmlEmail; //導入方法依賴的package包/類
/**
 * send mail
 */
@Test
public void test() {
    try {
        HtmlEmail htmlEmail = new HtmlEmail();
        htmlEmail.setHostName("smtp.qq.com");
        htmlEmail.setFrom("[email protected]", "[email protected]");
        htmlEmail.addTo("[email protected]");
        htmlEmail.addCc("[email protected]", "[email protected]");
        htmlEmail.setAuthentication("[email protected]", "TaylorSwift");
        htmlEmail.setSubject("email example");
        htmlEmail.setHtmlMsg("test apache email");
        htmlEmail.setCharset("UTF-8");
        htmlEmail.buildMimeMessage();
        htmlEmail.sendMimeMessage();
    } catch (EmailException e) {
        System.out.println(e.getMessage());
    }
}
 
開發者ID:sunlin901203,項目名稱:example-java,代碼行數:22,代碼來源:EmailExample.java

示例3: addEmailAddress

import org.apache.commons.mail.HtmlEmail; //導入方法依賴的package包/類
private void addEmailAddress(final HtmlEmail email, final String firstAddress, final EmailAddressType firstType)
		throws EmailException
{
	switch (firstType)
	{
		case To:
			email.addTo(firstAddress);
			break;
		case BCC:
			email.addBcc(firstAddress);
			break;
		case CC:
			email.addCc(firstAddress);
			break;
	}
}
 
開發者ID:bsutton,項目名稱:scoutmaster,代碼行數:17,代碼來源:SMTPSettingsDao.java

示例4: main

import org.apache.commons.mail.HtmlEmail; //導入方法依賴的package包/類
public static void main(String[] args) throws EmailException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName("smtp.example.com");
    email.setFrom("[email protected]", "From User");
    email.addTo("[email protected]", "To User");
    email.addTo("[email protected]", "To 2 User");
    email.addCc("[email protected]", "CC User");
    email.addBcc("[email protected]", "BCC User");
    email.setSubject("Sample Email Subject");
    email.setMsg("<p>This is body content.</p>");
    email.send();
}
 
開發者ID:dnstk,項目名稱:imgate,代碼行數:13,代碼來源:SendMailMain.java

示例5: sendHtmlEmail

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

示例6: sendHtmlMail

import org.apache.commons.mail.HtmlEmail; //導入方法依賴的package包/類
@Override
public void sendHtmlMail(Email cerberusEmail) throws Exception {

    HtmlEmail email = new HtmlEmail();
    email.setSmtpPort(cerberusEmail.getSmtpPort());
    email.setHostName(cerberusEmail.getHost());
    email.setFrom(cerberusEmail.getFrom());
    email.setSubject(cerberusEmail.getSubject());
    email.setHtmlMsg(cerberusEmail.getBody());
    email.setTLS(cerberusEmail.isSetTls());
    email.setDebug(true);

    if (!StringUtils.isNullOrEmpty(cerberusEmail.getUserName()) || !StringUtils.isNullOrEmpty(cerberusEmail.getPassword())) {
        email.setAuthentication(cerberusEmail.getUserName(), cerberusEmail.getPassword());
    }

    String[] destinataire = cerberusEmail.getTo().split(";");
    for (int i = 0; i < destinataire.length; i++) {
        String name;
        String emailaddress;
        if (destinataire[i].contains("<")) {
            String[] destinatairedata = destinataire[i].split("<");
            name = destinatairedata[0].trim();
            emailaddress = destinatairedata[1].replace(">", "").trim();
        } else {
            name = "";
            emailaddress = destinataire[i];
        }
        email.addTo(emailaddress, name);
    }

    if (!StringUtil.isNullOrEmpty(cerberusEmail.getCc())) {
        String[] copy = cerberusEmail.getCc().split(";");

        for (int i = 0; i < copy.length; i++) {
            String namecc;
            String emailaddresscc;
            if (copy[i].contains("<")) {
                String[] copydata = copy[i].split("<");
                namecc = copydata[0].trim();
                emailaddresscc = copydata[1].replace(">", "").trim();
            } else {
                namecc = "";
                emailaddresscc = copy[i];
            }
            email.addCc(emailaddresscc, namecc);
        }
    }

    email.send();

}
 
開發者ID:cerberustesting,項目名稱:cerberus-source,代碼行數:53,代碼來源:EmailService.java


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