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


Java MimeMessage.setSentDate方法代码示例

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


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

示例1: createCodeMessage

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
 * 创建一封邮件
 *
 * @param session     和服务器交互的会话
 * @param sendMail    发件人邮箱
 * @param receiveMail 收件人邮箱
 * @return
 * @throws Exception
 */
private MimeMessage createCodeMessage(Session session, String sendMail, String receiveMail) throws MessagingException, UnsupportedEncodingException {
    MimeMessage message = new MimeMessage(session);

    message.setFrom(new InternetAddress(sendMail, "吃在华科", "UTF-8"));

    message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(receiveMail, this.name, "UTF-8"));

    message.setSubject("吃在华科邮件注册验证码", "UTF-8");
    String content = this.name + ",你好, 您的验证码如下<br/>" + getCode() + "<p> 您不需要回复这封邮件。<p/>";
    message.setContent(content, "text/html;charset=UTF-8");
    message.setSentDate(new Date());
    message.saveChanges();

    return message;
}
 
开发者ID:GrayXu,项目名称:HustEating,代码行数:25,代码来源:Mail.java

示例2: sendEmail

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
@Override
public void sendEmail(String address, String subject, String content, Map<String, String> headers) throws Exception {
	Session session = MailUtilities.makeSession();
	if (session == null) {
		// LogService.getRoot().warning("Unable to create mail session. Not sending mail to "+address+".");
		LogService.getRoot().log(Level.WARNING, "com.rapidminer.tools.MailSenderSMTP.creating_mail_session_error",
				address);
	}
	MimeMessage msg = new MimeMessage(session);
	msg.setRecipients(Message.RecipientType.TO, address);
	msg.setFrom();
	msg.setSubject(subject, "UTF-8");
	msg.setSentDate(new Date());
	msg.setText(content, "UTF-8");

	if (headers != null) {
		for (Entry<String, String> header : headers.entrySet()) {
			msg.setHeader(header.getKey(), header.getValue());
		}
	}
	Transport.send(msg);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:MailSenderSMTP.java

示例3: process

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
@Override
public String process() {
	logger.info("Running inside MailBatchlet batchlet ");
	String fromAddress = stepContext.getProperties().getProperty("mail.from");
	String toAddress = stepContext.getProperties().getProperty("mail.to");

	try {
		MimeMessage m = new MimeMessage(mailSession);
		Address from = new InternetAddress(fromAddress);
		Address[] to = new InternetAddress[] { new InternetAddress(toAddress) };

		m.setFrom(from);
		m.setRecipients(TO, to);
		m.setSubject("Batch on wildfly executed");
		m.setSentDate(new java.util.Date());
		m.setContent("Job Execution id " + jobContext.getExecutionId() + " warned disk space getting low!",
				"text/plain");
		send(m);

	} catch (javax.mail.MessagingException e) {
		logger.log(SEVERE, "error send mail", e);

	}
	return COMPLETED.name();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:26,代码来源:MailBatchlet.java

示例4: sendHtmlEmail

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
public void sendHtmlEmail(EmailObject email) throws Exception {
    // 创建Session实例对象
    Session session = Session.getInstance(props, new EmailAuthenticator());

    // 创建MimeMessage实例对象
    MimeMessage message = new MimeMessage(session);
    // 设置邮件主题
    message.setSubject(email.getEmailSubject(),"utf-8");
    // 设置发送人
    message.setFrom(new InternetAddress(from));
    // 设置发送时间
    message.setSentDate(new Date());
    // 设置收件人
    message.setRecipients(MimeMessage.RecipientType.TO, InternetAddress.parse(email.getToEmail()));
    // 设置html内容为邮件正文,指定MIME类型为text/html类型,并指定字符编码为gbk
    message.setContent(email.getEmailContent(), "text/html;charset=utf-8");
    // 保存并生成最终的邮件内容
    message.saveChanges();
    // 发送邮件
    Transport.send(message);
    //记录邮件发送日志
    SendEmailLog sendEmailLog = new SendEmailLog();
    sendEmailLog.setToemail(email.getToEmail());
    sendEmailLog.setSubject(email.getEmailSubject());
    sendEmailLog.setSenddate(new Date());
    sendEmailLog.setContent(email.getEmailContent());
    sendEmailLogDao.insert(sendEmailLog);
}
 
开发者ID:NeilRen,项目名称:NEILREN4J,代码行数:29,代码来源:EmailUtils.java

示例5: send

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
@Override
public void send(String senderAddress, String senderName, String recipient, String content) {
    if (StringUtils.isBlank(senderAddress)) {
        throw new FeatureNotAvailable("3PID Email identity: sender address is empty - " +
                "You must set a value for notifications to work");
    }

    if (StringUtils.isBlank(content)) {
        throw new InternalServerError("Notification content is empty");
    }

    try {
        InternetAddress sender = new InternetAddress(senderAddress, senderName);
        MimeMessage msg = new MimeMessage(session, IOUtils.toInputStream(content, StandardCharsets.UTF_8));
        msg.setHeader("X-Mailer", "mxisd"); // FIXME set version
        msg.setSentDate(new Date());
        msg.setFrom(sender);
        msg.setRecipients(Message.RecipientType.TO, recipient);
        msg.saveChanges();

        log.info("Sending invite to {} via SMTP using {}:{}", recipient, cfg.getHost(), cfg.getPort());
        SMTPTransport transport = (SMTPTransport) session.getTransport("smtp");
        transport.setStartTLS(cfg.getTls() > 0);
        transport.setRequireStartTLS(cfg.getTls() > 1);

        log.info("Connecting to {}:{}", cfg.getHost(), cfg.getPort());
        transport.connect(cfg.getHost(), cfg.getPort(), cfg.getLogin(), cfg.getPassword());
        try {
            transport.sendMessage(msg, InternetAddress.parse(recipient));
            log.info("Invite to {} was sent", recipient);
        } finally {
            transport.close();
        }
    } catch (UnsupportedEncodingException | MessagingException e) {
        throw new RuntimeException("Unable to send e-mail invite to " + recipient, e);
    }
}
 
开发者ID:kamax-io,项目名称:mxisd,代码行数:38,代码来源:EmailSmtpConnector.java

示例6: createMimeMessage

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
 * 创建一封只包含文本的简单邮件
 *
 * @param session
 *            和服务器交互的会话
 * @param sendMail
 *            发件人邮箱
 * @param receiveMail
 *            收件人邮箱
 * @return
 * @throws Exception
 */
public static MimeMessage createMimeMessage(Session session, String sendMail, String receiveMail, String username,String pwd)
		throws Exception {
	// 1. 创建一封邮件
	MimeMessage message = new MimeMessage(session);

	// 2. From: 发件人(昵称有广告嫌疑,避免被邮件服务器误认为是滥发广告以至返回失败,请修改昵称)
	message.setFrom(new InternetAddress(sendMail, "Mircle", "UTF-8"));

	// 3. To: 收件人(可以增加多个收件人、抄送、密送)
	message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(receiveMail, "", "UTF-8"));

	// 4. Subject: 邮件主题(标题有广告嫌疑,避免被邮件服务器误认为是滥发广告以至返回失败,请修改标题)
	message.setSubject(subject, "UTF-8");

	// 5. Content: 邮件正文(可以使用html标签)(内容有广告嫌疑,避免被邮件服务器误认为是滥发广告以至返回失败,请修改发送内容)
	message.setContent(getContent(username,pwd), "text/html;charset=UTF-8");

	// 6. 设置发件时间
	message.setSentDate(new Date());

	// 7. 保存设置
	message.saveChanges();

	return message;
}
 
开发者ID:miracle857,项目名称:weibo,代码行数:38,代码来源:Mail.java

示例7: sendAccountActivateEmail

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
public static void sendAccountActivateEmail(String email, String uuid, int userId) {
  Session session;
  try {
    session = getSession();
    MimeMessage message = new MimeMessage(session);
    message.setSubject("������֤��");
    message.setSentDate(new Date());
    message.setFrom(new InternetAddress(FROM));
    message.setRecipient(RecipientType.TO, new InternetAddress(email));
    message.setContent("�����û�"+userId+":������֤��Ϊ��"+uuid,
        "text/html;charset=utf-8");
    message.saveChanges();
    Transport.send(message);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:18,代码来源:EmailUtils.java

示例8: sendMail

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
 * Sends an email.
 * 
 * @param from
 *            The Email-address from the sender of this mail.
 * @param to
 *            The Email-address of the receiver of this mail.
 * @param subject
 *            The subject of the mail.
 * @param body
 *            The content of the mail.
 * @throws MailSendingException
 *             When sending the mail failed.
 */
public void sendMail(final String from, final String to, final String subject, final String body)
        throws MailSendingException {
    final MimeMessage message = new MimeMessage(session);
    try {
        message.setFrom(new InternetAddress(from));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSentDate(new Date());
        message.setSubject(subject);
        message.setText(body);

        Transport.send(message);
    } catch (final MessagingException e) {
        throw new MailSendingException("Sending an email failed.", e);
    }

}
 
开发者ID:rbi,项目名称:trading4j,代码行数:31,代码来源:MailSender.java

示例9: createMimeMessage

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
 *
 * @param session 和服务器交互的会话
 * @param mail 邮件内容
 * @return
 * @throws Exception
 */
private static MimeMessage createMimeMessage(Session session, String SendAccount, Mail mail) throws Exception {
    MimeMessage message = new MimeMessage(session);
    //From: 发件人
    message.setFrom(new InternetAddress(SendAccount, mail.getPersonal(), "UTF-8"));
    // To: 收件人
    message.setRecipients(MimeMessage.RecipientType.TO, mail.getAddresses());
    // Subject: 邮件主题
    message.setSubject(mail.getSubject(), "UTF-8");
    // Content: 邮件正文(可以使用html标签)
    message.setContent(mail.getContext(), "text/html;charset=UTF-8");
    // 设置发件时间
    message.setSentDate(new Date());
    message.saveChanges();
    return message;
}
 
开发者ID:BetaSummer,项目名称:sztw,代码行数:23,代码来源:MailCore.java

示例10: createMimeMessage

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
private MimeMessage createMimeMessage(String from, String subject, String body, Date date) throws AddressException, MessagingException {
    MimeMessage msg = new MimeMessage(greenMail.getSmtp().createSession());
    msg.setFrom(new InternetAddress(from));
    msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress(TEST_RECIP));
    msg.setSubject(subject);
    msg.setText(body);
    msg.setSentDate(date != null ? date : new Date());
    return msg;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:11,代码来源:TestMailUtil.java

示例11: send

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
public void send(String to, String cc, String bcc, String subject,
        String content, JavamailConfig javamailConfig)
        throws MessagingException {
    logger.debug("send : {}, {}", to, subject);

    try {
        Properties props = createSmtpProperties(javamailConfig);
        String username = javamailConfig.getUsername();
        String password = javamailConfig.getPassword();

        // 创建Session实例对象
        Session session = Session.getInstance(props, new SmtpAuthenticator(
                username, password));
        session.setDebug(false);

        // 创建MimeMessage实例对象
        MimeMessage message = new MimeMessage(session);
        // 设置邮件主题
        message.setSubject(subject);
        // 设置发送人
        message.setFrom(new InternetAddress(username));
        // 设置发送时间
        message.setSentDate(new Date());
        // 设置收件人
        message.setRecipients(RecipientType.TO, InternetAddress.parse(to));
        // 设置html内容为邮件正文,指定MIME类型为text/html类型,并指定字符编码为gbk
        message.setContent(content, "text/html;charset=gbk");

        // 保存并生成最终的邮件内容
        message.saveChanges();

        // 发送邮件
        Transport.send(message);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:38,代码来源:JavamailService.java

示例12: send

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
public boolean send() throws Exception {
    Properties props = _setProperties();
    Session session = Session.getInstance(props, this);
    MimeMessage msg = new MimeMessage(session);
    msg.setSubject(subject);
    msg.setFrom(new InternetAddress("[email protected]"));
    msg.setRecipients(MimeMessage.RecipientType.TO, new InternetAddress[] {
            new InternetAddress("[email protected]")
    });
    msg.setSentDate(new Date());
    msg.setContent(multipart);
    Transport.send(msg);
    return true;
}
 
开发者ID:KursX,项目名称:Parallator,代码行数:15,代码来源:MailSender.java

示例13: send

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
private void send(MimeMessage msg) throws MessagingException {
    msg.setHeader("X-Mailer", "matrix-appservice-email");
    msg.setSentDate(new Date());
    msg.setRecipients(Message.RecipientType.TO, getIdentity());

    SMTPTransport transport = (SMTPTransport) session.getTransport("smtp");
    transport.setStartTLS(cfg.getTls() > 0);
    transport.setRequireStartTLS(cfg.getTls() > 1);
    transport.connect(cfg.getHost(), cfg.getPort(), cfg.getLogin(), cfg.getPassword());
    log.info("Sending email via SMTP using {}:{}", cfg.getHost(), cfg.getPort());

    try {
        transport.sendMessage(msg, InternetAddress.parse(getIdentity()));
    } catch (MessagingException e) {
        log.error("mmm", e);
    } finally {
        transport.close();
    }
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:20,代码来源:EmailEndPoint.java

示例14: sendMail

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
public void sendMail(String account) throws Exception {
	message = new MimeMessage(session);
	message.setFrom(new InternetAddress("[email protected]"));
	message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(account, false));
	message.setSubject("DO NOT REPLY");
	message.setDataHandler(new DataHandler(new ByteArrayDataSource(getMailContent(), "text/html")));
	message.setSentDate(new Date());

	transport = session.getTransport();
	transport.connect("smtp-mail.outlook.com", "[email protected]", "BaoZJ960606");
	transport.sendMessage(message, message.getAllRecipients());
	transport.close();
}
 
开发者ID:CongBao,项目名称:baozijuan.com,代码行数:14,代码来源:MailManager.java

示例15: createMimeMessage

import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
private static MimeMessage createMimeMessage(Session session, String sendMail, 
		String receiveMail, String password) throws Exception {

    MimeMessage message = new MimeMessage(session);


    message.setFrom(new InternetAddress(sendMail, "易购房", "UTF-8"));

 
    message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(receiveMail, "亲爱的用户", "UTF-8"));

    // 4. Subject: 主题
    message.setSubject("找回密码", "UTF-8");

    // 5. Content: 内容
    message.setContent("您好,以下为您的密码,请及时修改~\n" + "密码:" + password, "text/html;charset=UTF-8");


    message.setSentDate(new Date());

    message.saveChanges();

    return message;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:25,代码来源:Tool.java


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