当前位置: 首页>>代码示例>>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;未经允许,请勿转载。