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

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

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

Message.setSentDate介绍

[英]Set the sent date of this message.
[中]设置此邮件的发送日期。

代码示例

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

msg.setContent(mp);
 msg.setSentDate(new Date());
 Transport.send(msg);
} catch(MessagingException e) {

代码示例来源:origin: aa112901/remusic

mailMessage.setRecipient(Message.RecipientType.TO, to);
mailMessage.setSubject(title);
mailMessage.setSentDate(new Date());
mailMessage.setText(content);
transport.sendMessage(mailMessage, mailMessage.getAllRecipients());

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

message.setSentDate(new Date());

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

msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setFrom(fromAddress);
if (highPriority) {

代码示例来源:origin: pentaho/pentaho-kettle

msg.setSentDate( new Date() );
StringBuilder messageText = new StringBuilder();

代码示例来源:origin: kiegroup/jbpm

msg.setSentDate( new Date() );

代码示例来源:origin: pentaho/pentaho-kettle

msg.setSentDate( new Date() );
StringBuilder messageText = new StringBuilder();
String endRow = isUseHTML() ? "<br>" : Const.CR;

代码示例来源:origin: apache/nifi

message.setSentDate(new Date());

代码示例来源:origin: apache/nifi

@Override
public void notify(final NotificationContext context, final NotificationType notificationType, final String subject, final String messageText) throws NotificationFailedException {
  final Properties properties = getMailProperties(context);
  final Session mailSession = createMailSession(properties);
  final Message message = new MimeMessage(mailSession);
  try {
    message.setFrom(InternetAddress.parse(context.getProperty(FROM).evaluateAttributeExpressions().getValue())[0]);
    final InternetAddress[] toAddresses = toInetAddresses(context.getProperty(TO).evaluateAttributeExpressions().getValue());
    message.setRecipients(RecipientType.TO, toAddresses);
    final InternetAddress[] ccAddresses = toInetAddresses(context.getProperty(CC).evaluateAttributeExpressions().getValue());
    message.setRecipients(RecipientType.CC, ccAddresses);
    final InternetAddress[] bccAddresses = toInetAddresses(context.getProperty(BCC).evaluateAttributeExpressions().getValue());
    message.setRecipients(RecipientType.BCC, bccAddresses);
    message.setHeader("X-Mailer", context.getProperty(HEADER_XMAILER).evaluateAttributeExpressions().getValue());
    message.setSubject(subject);
    final String contentType = context.getProperty(CONTENT_TYPE).evaluateAttributeExpressions().getValue();
    message.setContent(messageText, contentType);
    message.setSentDate(new Date());
    Transport.send(message);
  } catch (final ProcessException | MessagingException e) {
    throw new NotificationFailedException("Failed to send E-mail Notification", e);
  }
}

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

Properties properties = System.getProperties();
 properties.put("mail.smtp.host", server);
 properties.put("mail.smtp.port", "" + port);
 Session session = Session.getInstance(properties);
 Transport transport = session.getTransport("smtp");
 transport.connect(server, username, password);
 for (int i = 0; i < count; i++) {
   Message message = new MimeMessage(session);
   message.setFrom(new InternetAddress(from));
   InternetAddress[] address = {new InternetAddress(to)};
   message.setRecipients(Message.RecipientType.TO, address);
   message.setSubject(subject + "JavaMail API");
   message.setSentDate(new Date());
   setHTMLContent(message);
   message.saveChanges();
   transport.sendMessage(message, address);
 }
 transport.close();

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

msg.setSentDate( new Date());
msg.setSubject( "Hello World!" );

代码示例来源:origin: apache/log4j

msg.setContent(mp);
 msg.setSentDate(new Date());
 Transport.send(msg);
} catch(MessagingException e) {

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

/**
 * Creates all of the envelope information for a message.
 * This method is safe to call outside of a lock because the message
 * provides the safe snapshot of the mail properties.
 * @param msg the Message to write the envelope information.
 * @param priority true for high priority.
 */
private void envelopeFor(Message msg, boolean priority) {
  setAcceptLang(msg);
  setFrom(msg);
  if (!setRecipient(msg, "mail.to", Message.RecipientType.TO)) {
    setDefaultRecipient(msg, Message.RecipientType.TO);
  }
  setRecipient(msg, "mail.cc", Message.RecipientType.CC);
  setRecipient(msg, "mail.bcc", Message.RecipientType.BCC);
  setReplyTo(msg);
  setSender(msg);
  setMailer(msg);
  setAutoSubmitted(msg);
  if (priority) {
    setPriority(msg);
  }
  try {
    msg.setSentDate(new java.util.Date());
  } catch (final MessagingException ME) {
    reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
  }
}

代码示例来源:origin: webx/citrus

/** 发送一个email。 */
public void send(Message message, MailTransportHandler handler) throws MailException {
  boolean autoClose = false;
  setHandler(handler);
  if (!isConnected()) {
    autoClose = true;
    connect();
  }
  try {
    message.setSentDate(new Date());
    if (getHandler() != null) {
      getHandler().processMessage(message);
    }
    message.saveChanges();
    Address[] recipients = message.getAllRecipients();
    if (isEmptyArray(recipients)) {
      throw new MailException("No recipient was specified in mail");
    }
    transport.sendMessage(message, recipients);
  } catch (MessagingException me) {
    throw new MailException("Could not send message", me);
  } finally {
    if (autoClose) {
      close();
    }
  }
}

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

/**
 * Creates all of the envelope information for a message.
 * This method is safe to call outside of a lock because the message
 * provides the safe snapshot of the mail properties.
 * @param msg the Message to write the envelope information.
 * @param priority true for high priority.
 */
private void envelopeFor(Message msg, boolean priority) {
  setAcceptLang(msg);
  setFrom(msg);
  if (!setRecipient(msg, "mail.to", Message.RecipientType.TO)) {
    setDefaultRecipient(msg, Message.RecipientType.TO);
  }
  setRecipient(msg, "mail.cc", Message.RecipientType.CC);
  setRecipient(msg, "mail.bcc", Message.RecipientType.BCC);
  setReplyTo(msg);
  setSender(msg);
  setMailer(msg);
  setAutoSubmitted(msg);
  if (priority) {
    setPriority(msg);
  }
  try {
    msg.setSentDate(new java.util.Date());
  } catch (final MessagingException ME) {
    reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
  }
}

代码示例来源:origin: webx/citrus

/** 发送一个email。 */
public void send(Message message, MailTransportHandler handler) throws MailException {
  boolean autoClose = false;
  setHandler(handler);
  if (!isConnected()) {
    autoClose = true;
    connect();
  }
  try {
    message.setSentDate(new Date());
    if (getHandler() != null) {
      getHandler().processMessage(message);
    }
    message.saveChanges();
    Address[] recipients = message.getAllRecipients();
    if (isEmptyArray(recipients)) {
      throw new MailException("No recipient was specified in mail");
    }
    transport.sendMessage(message, recipients);
  } catch (MessagingException me) {
    throw new MailException("Could not send message", me);
  } finally {
    if (autoClose) {
      close();
    }
  }
}

代码示例来源:origin: google/mail-importer

@Override
public void setSentDate(Date date) throws RuntimeMessagingException {
 try {
  delegate.setSentDate(date);
 } catch (MessagingException e) {
  throw new RuntimeMessagingException(e);
 }
}

代码示例来源:origin: jlfex/hermes

/**
 * 发送邮件
 */
public void send() {
  try {
    message.setSentDate(new Date());
    Transport.send(message);
  } catch (MessagingException e) {
    throw new ServiceException("cannot send mail.", "exception.mail.send", e);
  }
}

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

try {
 Properties props = System.getProperties();
 props.put("mail.smtp.auth", "true");
 Session mailSession = Session.getDefaultInstance(props, null);
 Message msg = new MimeMessage(mailSession);
 msg.setFrom(new InternetAddress(from));
 InternetAddress[] address = {new InternetAddress(to)};
 msg.setRecipients(Message.RecipientType.TO, address);
 msg.setSubject(compression);
 msg.setText(body);
 msg.setSentDate(new Date());

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

Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = { new InternetAddress(toAddress) };
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(message);

相关文章