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


Java HtmlEmail.setHtmlMsg方法代码示例

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


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

示例1: sendEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
private void sendEmail(String content) throws Exception {
	System.out.println("Send Email:");
	if (!Config.getBoolean("email.enabled")) {
		return;
	}
	
	HtmlEmail email = new HtmlEmail();
	for (String receipt : Config.getArrayProperty("report.email.recipients")) {
		email.addTo(receipt);
	}
	email.setFrom(Config.getProperty("report.email.from"));
	email.setSubject(Config.getProperty("report.email.subject"));
	email.setHtmlMsg(content);
	email.setHostName(Config.getProperty("report.email.host"));
	email.setAuthentication(Config.getProperty("report.email.username"), 
			Config.getProperty("report.email.password"));
	email.send();
}
 
开发者ID:21ca,项目名称:selenium-testng-template,代码行数:19,代码来源:SendEmailReporter.java

示例2: 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

示例3: sendEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
private void sendEmail() throws EmailException
{
	HtmlEmail email = new HtmlEmail();
	email.setHostName(smtpServer);
	if (smtpUser != null && smtpPassword != null) email.setAuthentication(smtpUser, smtpPassword);

	if (smtpSslPort != null)
	{
		email.setSSL(true);
		email.setSslSmtpPort(smtpSslPort);
	}

	Session session = email.getMailSession();
	Properties properties = session.getProperties();
	properties.setProperty("mail.smtp.connectiontimeout", "20000");
	properties.setProperty("mail.smtp.timeout", "20000");

	email.addTo(recipientEmailAddress, recipientEmailAddress);
	email.setFrom(smtpUser, smtpUser);

	email.setSubject(subject);
	email.setHtmlMsg(contents);
	email.setTextMsg(contents);
	email.send();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:26,代码来源:Log4JGmailExecutorTask.java

示例4: 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

示例5: sendHtmlAndTextEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
@Override
public void sendHtmlAndTextEmail(String to, String subject, String htmlBody, String textBody) throws ServiceException {
	HtmlEmail email = new HtmlEmail();

	try {
		setupEmail(email);
		validateAddress(to);
		email.addTo(to);
		email.setSubject(subject);
		email.setHtmlMsg(htmlBody);
		email.setTextMsg(textBody);
		email.send();
	} catch (EmailException e) {
		log.error("ZZZ.EmailException. To: " + to + " Subject: " + subject, e);
		throw new ServiceException("Unable to send email.", e);
	}
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:18,代码来源:EmailServiceImpl.java

示例6: sendHtmlEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
@Override
public void sendHtmlEmail(String to, String subject, String htmlBody) throws ServiceException {
	HtmlEmail email = new HtmlEmail();

	try {
		setupEmail(email);
		validateAddress(to);
		email.addTo(to);
		email.setSubject(subject);
		email.setHtmlMsg(htmlBody);
		email.send();
	} catch (EmailException e) {
		log.error("ZZZ.EmailException. To: " + to + " Subject: " + subject, e);
		throw new ServiceException("Unable to send email.", e);
	}
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:17,代码来源:EmailServiceImpl.java

示例7: sendEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
public void sendEmail() {
	HtmlEmail email = new HtmlEmail();
	try {
		email.setHostName(emailHostName);
		email.setSmtpPort(smtpPort);
		email.setAuthenticator(new DefaultAuthenticator(emailLogin,
				emailPassword));
		email.setSSLOnConnect(emailSSL);
		email.setStartTLSEnabled(startTLS);
		email.setFrom(emailSender);
		email.setSubject(title);
		email.setHtmlMsg(htmlMessage);
		email.addTo(emailRecipient);
		email.send();
		System.out.println("Email sent: " + title);
	} catch (EmailException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:RobCubed,项目名称:ShipworksWeeklyReports,代码行数:21,代码来源:Email.java

示例8: sendWithHtml

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
@Override
public void sendWithHtml(String recipient, String subject, String content) throws SendMailException {
	Assert.hasText(recipient);
	Assert.hasText(subject);
	Assert.hasText(content);
	
	HtmlEmail email = new HtmlEmail();
	email.setHostName(host);
	email.setAuthenticator(new DefaultAuthenticator(loginName, loginPassword));
	email.setSmtpPort(port);
	email.setTLS(tls);

	try {
		email.setCharset("UTF-8"); // specify the charset.
		email.setFrom(fromAddress, fromName);
		email.setSubject(subject);
		email.setHtmlMsg(content);
		//email.setMsg(""); // can set plain text either
		email.addTo(recipient);
		email.send();
	} catch (EmailException e) {
		throw new SendMailException(
				String.format("Failed to send mail to %s.", recipient), e);
	}
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:26,代码来源:SmtpMailSender.java

示例9: send

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
/**
 * Send email with subject and message body.
 * @param subject the email subject.
 * @param body the email body.
 */
public void send(String subject, String body) {
    try {
        HtmlEmail email = new HtmlEmail();
        email.setHostName(configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_HOST, "localhost"));
        email.setSmtpPort(configuration.getInt(CONFKEY_REPORTS_MAILER_SMTP_PORT, 465));
        email.setAuthenticator(new DefaultAuthenticator(
            configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_USER, "anonymous"),
            configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_PASS, "guest")
        ));
        email.setStartTLSEnabled(false);
        email.setSSLOnConnect(configuration.getBoolean(CONFKEY_REPORTS_MAILER_SMTP_SSL, true));
        email.setFrom(configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_FROM, ""));
        email.setSubject(subject);
        email.setHtmlMsg(body);
        String[] receivers = configuration.getStringArray(CONFKEY_REPORTS_MAILER_SMTP_TO);
        for (String receiver : receivers) {
            email.addTo(receiver);
        }
        email.send();
        LOG.info("Report sent with email to " + email.getToAddresses().toString() + " (\"" + subject + "\")");
    } catch (EmailException e) {
        LOG.error(e.getMessage(), e);
    }
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:30,代码来源:ReportMailer.java

示例10: process

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
@Override
public void process(Item item, Logger logger) throws ItemHandlerException {

	HtmlEmail email = new HtmlEmail();

	try {
		email.addTo(to);
		setFrom(email, item);
		setSentDate(email, item, logger);
		email.setSubject(item.getTitle());
		email.setHtmlMsg(getHtmlMsg(item));
		email.setMailSession(getMailSession());
		email.send();
	}
	catch (Exception e) {
		throw new ItemHandlerException("Could not send email", e);
	}

	logger.log("Sent item email to " + to);
}
 
开发者ID:bmunzenb,项目名称:feed-buddy,代码行数:21,代码来源:SendEmail.java

示例11: sendHtmlEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
public static void sendHtmlEmail(String to, String subject, String template, Map<String, Object> variables) {

        try {
            final HtmlEmail email = new HtmlEmail();
            setupEmail(email, to, subject, template, variables);
            email.setHtmlMsg(EmailUtil.getHtmlBody(template, variables));
            email.setTextMsg(EmailUtil.getTextBody(template, variables));
            email.setSocketConnectionTimeout(Configuration.getSmtpConnectTimeout());

            email.send();
        } catch (Exception e) {
            LOGGER.error("Error sending HTML email", e);
        }
    }
 
开发者ID:CROW-NDOV,项目名称:displaydirect,代码行数:15,代码来源:EmailUtil.java

示例12: simple

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
@Test
public void simple() throws Exception {

	new ProxyInitializable().initialize();

	HtmlEmail email = new HtmlEmail();
	email.setHostName("mail.myserver.com");
	email.addTo("[email protected]", "John Doe");
	// email.setFrom("[email protected]", "Me");
	email.setSubject("Test email with inline image");

	// embed the image and get the content id
	// URL url = new URL("https://i.stack.imgur.com/r7Nij.jpg?s=32&g=1");
	String cid = email.embed(new File("123.jpg"));

	// set the html message
	email.setHtmlMsg("<html>The apache logo - <img src=\"cid:" + cid + "\"></html>");

	// set the alternative message
	email.setTextMsg("Your email client does not support HTML messages");

	MimeMessage mimeMessage = email.getMimeMessage();
	System.out.println(mimeMessage);

	System.out.println(email.sendMimeMessage());
	// send the email
	email.send();
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:29,代码来源:MimeConverter.java

示例13: sendEmail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
/**
 * This is a convenience method for sending and email to 1 recipient using the configuration file settings.
 * @throws EmailException 
 */
public static void sendEmail(String toEmailAddress, String toName, String fromEmailAddress, String fromName, String subject, String textContents, String htmlContents) throws EmailException
{
	HtmlEmail htmlEmail = getHtmlEmail();

	htmlEmail.addTo(toEmailAddress, toName);
	htmlEmail.setFrom(fromEmailAddress, fromName);

	htmlEmail.setSubject(subject);
	if (textContents != null) htmlEmail.setTextMsg(textContents);
	if (htmlContents != null) htmlEmail.setHtmlMsg(htmlContents);

	//htmlEmail.getMailSession().setDebug(true);
	htmlEmail.send();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:19,代码来源:EmailUtilsOld.java

示例14: sendHtmlMail

import org.apache.commons.mail.HtmlEmail; //导入方法依赖的package包/类
private void sendHtmlMail(String fromEmail, String fromPasswd,String fromName,
		String host,List<String> toEmailList,MailMsg mailMsg){
	HtmlEmail email = new HtmlEmail();
	try {
    	initEmail(email, fromEmail, fromPasswd, fromName,host, toEmailList, mailMsg);
		email.setHtmlMsg(mailMsg.getContent());
    	email.send();
    } 
    catch (EmailException e) {
    	e.printStackTrace();
    }
}
 
开发者ID:yinshipeng,项目名称:sosoapi-base,代码行数:13,代码来源:ApacheMailServiceImpl.java

示例15: 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


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