當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。