javax.mail.internet.MimeMessage.setSentDate()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(256)

本文整理了Java中javax.mail.internet.MimeMessage.setSentDate()方法的一些代码示例,展示了MimeMessage.setSentDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeMessage.setSentDate()方法的具体详情如下:
包路径:javax.mail.internet.MimeMessage
类名称:MimeMessage
方法名:setSentDate

MimeMessage.setSentDate介绍

[英]Set the RFC 822 "Date" header field. This is the date on which the creator of the message indicates that the message is complete and ready for delivery. If the date parameter is null, the existing "Date" field is removed.
[中]设置RFC 822“日期”标题字段。这是邮件创建者表示邮件已完成并准备好交付的日期。如果日期参数为null,则现有的“日期”字段将被删除。

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Sets sent date in msgToSet with sent date from emailWithData.
 *
 * @param emailWithData {@link Email} with data
 * @param msgToSet      {@link MimeMessage} to set data into.
 * @throws MessagingException if there is a failure
 */
private void setSentDate(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
  Date date = emailWithData.sentDate();
  if (date == null) {
    date = new Date();
  }
  msgToSet.setSentDate(date);
}

代码示例来源:origin: gocd/gocd

public MimeMessage createMessage(String from, String to, String subject, String body)
    throws MessagingException {
  MimeMessage msg = new MimeMessage(session);
  msg.setFrom(new InternetAddress(from));
  msg.setRecipients(TO, to);
  msg.setSubject(subject);
  msg.setContent(msg, "text/plain");
  msg.setSentDate(new Date());
  msg.setText(body);
  msg.setSender(new InternetAddress(from));
  msg.setReplyTo(new InternetAddress[]{new InternetAddress(from)});
  return msg;
}

代码示例来源:origin: stackoverflow.com

mp.addBodyPart(mbp);
message.setContent(mp);
message.setSentDate(new java.util.Date());

代码示例来源:origin: quartz-scheduler/quartz

protected MimeMessage prepareMimeMessage(MailInfo mailInfo)
  throws MessagingException {
  Session session = getMailSession(mailInfo);
  MimeMessage mimeMessage = new MimeMessage(session);
  Address[] toAddresses = InternetAddress.parse(mailInfo.getTo());
  mimeMessage.setRecipients(Message.RecipientType.TO, toAddresses);
  if (mailInfo.getCc() != null) {
    Address[] ccAddresses = InternetAddress.parse(mailInfo.getCc());
    mimeMessage.setRecipients(Message.RecipientType.CC, ccAddresses);
  }
  mimeMessage.setFrom(new InternetAddress(mailInfo.getFrom()));
  
  if (mailInfo.getReplyTo() != null) {
    mimeMessage.setReplyTo(new InternetAddress[]{new InternetAddress(mailInfo.getReplyTo())});
  }
  
  mimeMessage.setSubject(mailInfo.getSubject());
  
  mimeMessage.setSentDate(new Date());
  setMimeMessageContent(mimeMessage, mailInfo);
  return mimeMessage;
}

代码示例来源:origin: stackoverflow.com

msg.setSentDate(new Date());

代码示例来源:origin: looly/hutool

msg.setSentDate(new Date());

代码示例来源:origin: looly/hutool

msg.setSentDate(new Date());

代码示例来源:origin: traccar/traccar

message.setSentDate(new Date());

代码示例来源:origin: stackoverflow.com

msg.setSentDate(new Date());

代码示例来源:origin: loklak/loklak_server

message.addHeader("format", "flowed");
message.addHeader("Content-Transfer-Encoding", "8bit");
message.setSentDate(new Date());
message.setReplyTo(new Address[]{new InternetAddress(senderEmail, displayname)});
message.setFrom(new InternetAddress(senderEmail, displayname));

代码示例来源:origin: spring-projects/spring-framework

try {
  if (mimeMessage.getSentDate() == null) {
    mimeMessage.setSentDate(new Date());

代码示例来源:origin: org.springframework/spring-context-support

try {
  if (mimeMessage.getSentDate() == null) {
    mimeMessage.setSentDate(new Date());

代码示例来源:origin: bill1012/AdminEAP

/**
 * 群发邮件
 *
 * @param recipients 收件人们
 * @param subject    主题
 * @param content    内容
 * @throws AddressException
 * @throws MessagingException
 */
public void send(List<String> recipients, String subject, Object content)
    throws AddressException, MessagingException {
  // 创建mime类型邮件
  final MimeMessage message = new MimeMessage(session);
  // 设置发信人
  message.setFrom(new InternetAddress(authenticator.getUsername()));
  message.setSentDate(new Date());
  // 设置收件人们
  final int num = recipients.size();
  InternetAddress[] addresses = new InternetAddress[num];
  for (int i = 0; i < num; i++) {
    addresses[i] = new InternetAddress(recipients.get(i));
  }
  message.setRecipients(MimeMessage.RecipientType.TO, addresses);
  // 设置主题
  message.setSubject(subject);
  // 设置邮件内容
  message.setContent(content.toString(), "text/html;charset=utf-8");
  // 发送
  Transport.send(message);
}

代码示例来源:origin: bill1012/AdminEAP

/**
 * 发送邮件
 *
 * @param recipient 收件人邮箱地址
 * @param subject   邮件主题
 * @param content   邮件内容
 * @throws AddressException
 * @throws MessagingException
 */
public void send(String recipient, String subject, Object content)
    throws AddressException, MessagingException {
  // 创建mime类型邮件
  final MimeMessage message = new MimeMessage(session);
  // 设置发信人
  message.setFrom(new InternetAddress(authenticator.getUsername()));
  // 设置收件人
  message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(recipient));
  // 设置主题
  message.setSubject(subject);
  message.setSentDate(new Date());
  // 设置邮件内容
  message.setContent(content.toString(), "text/html;charset=utf-8");
  // 发送
  Transport.send(message);
}

代码示例来源:origin: stackoverflow.com

msg.setSentDate(new Date());

代码示例来源:origin: camunda/camunda-bpm-platform

mimeMsg.setContent(mp);
mimeMsg.setSentDate(new Date());
addInfo("About to send out SMTP message \"" + subjectStr + "\" to " + Arrays.toString(toAddressArray));
Transport.send(mimeMsg);

代码示例来源:origin: com.sun.mail/javax.mail

setHeader("MIME-Version", "1.0");
if (getHeader("Date") == null)
  setSentDate(new Date());
  updateMessageID();

代码示例来源:origin: jamesagnew/hapi-fhir

email.setSubject(subject);
  email.setText(body);
  email.setSentDate(new Date());
  email.addHeader("X-FHIR-Subscription", subscriptionId);
} catch (MessagingException e) {

代码示例来源:origin: ops4j/org.ops4j.pax.logging

protected void sendMultipartMessage(final MimeMessage msg, final MimeMultipart mp) throws MessagingException {
  synchronized (msg) {
    msg.setContent(mp);
    msg.setSentDate(new Date());
    Transport.send(msg);
  }
}

代码示例来源:origin: stackoverflow.com

MimeMessage msg = mailSender.createMimeMessage();
msg.setFrom(new InternetAddress(EMAIL_SENDER_ADDRESS, EMAIL_SENDER_PERSONAL));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setContent(text, "text/html; charset=UTF-8");
for (EmailInternetAddress emailInternetAddress  :emailInternetAddresses) {
  msg.addRecipient(emailInternetAddress.getRecipientType(),
        emailInternetAddress.getInternetAddress());
  }
mailSender.send(msg);

相关文章

MimeMessage类方法