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

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

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

MimeMessage.setHeader介绍

[英]Set the value for this header_name. Replaces all existing header values with this new value. Note that RFC 822 headers must contain only US-ASCII characters, so a header that contains non US-ASCII characters must have been encoded by the caller as per the rules of RFC 2047.
[中]设置此标题名称的值。用此新值替换所有现有标题值。请注意,RFC 822标头必须仅包含US-ASCII字符,因此包含非US-ASCII字符的标头必须由调用方按照RFC 2047的规则进行编码。

代码示例

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

/**
 * Set the priority ("X-Priority" header) of the message.
 * @param priority the priority value;
 * typically between 1 (highest) and 5 (lowest)
 * @throws MessagingException in case of errors
 */
public void setPriority(int priority) throws MessagingException {
  this.mimeMessage.setHeader(HEADER_PRIORITY, Integer.toString(priority));
}

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

/**
 * Set the priority ("X-Priority" header) of the message.
 * @param priority the priority value;
 * typically between 1 (highest) and 5 (lowest)
 * @throws MessagingException in case of errors
 */
public void setPriority(int priority) throws MessagingException {
  this.mimeMessage.setHeader(HEADER_PRIORITY, Integer.toString(priority));
}

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

MimeMessage msg = new MimeMessage(session);
msg.setHeader("Content-Type", encodingOptions);
msg.setFrom(new javax.mail.internet.InternetAddress(emailFrom));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(emailTo));

msg.setSubject(subject, "UTF-8");

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

/**
 * Sets headers in msgToSet with headers 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 setHeaders(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
  final Map<String, String> headers = emailWithData.headers();
  if (headers != null) {
    for (final Map.Entry<String, String> entry : headers.entrySet()) {
      msgToSet.setHeader(entry.getKey(), entry.getValue());
    }
  }
}

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

if (messageId != null) {
  mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);

代码示例来源:origin: igniterealtime/Openfire

java.util.Locale.US);
format.setTimeZone(JiveGlobals.getTimeZone());
message.setHeader("Date", format.format(new Date()));
message.setHeader("Content-Transfer-Encoding", "8bit");
message.setRecipient(Message.RecipientType.TO, to);
message.setFrom(from);

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

if (messageId != null) {
  mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);

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

/**
 * Set the "Content-MD5" header field of this Message.
 *
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
public void setContentMD5(String md5) throws MessagingException {
setHeader("Content-MD5", md5);
}

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

/**
 * Set the "Content-MD5" header field of this Message.
 *
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
@Override
public void setContentMD5(String md5) throws MessagingException {
setHeader("Content-MD5", md5);
}

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

/**
 * Update the Message-ID header.  This method is called
 * by the <code>updateHeaders</code> and allows a subclass
 * to override only the algorithm for choosing a Message-ID.
 *
 * @exception      MessagingException for failures
 * @since        JavaMail 1.4
 */
protected void updateMessageID() throws MessagingException {
setHeader("Message-ID", 
   "<" + UniqueValue.getUniqueMessageIDValue(session) + ">");
   
}

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

/**
 * Update the Message-ID header.  This method is called
 * by the <code>updateHeaders</code> and allows a subclass
 * to override only the algorithm for choosing a Message-ID.
 *
 * @exception      MessagingException for failures
 * @since        JavaMail 1.4
 */
protected void updateMessageID() throws MessagingException {
setHeader("Message-ID", 
   "<" + UniqueValue.getUniqueMessageIDValue(session) + ">");
   
}

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

/**
 * Set the "Content-ID" header field of this Message.
 * If the <code>cid</code> parameter is null, any existing 
 * "Content-ID" is removed.
 *
 * @param    cid    the content ID
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
public void setContentID(String cid) throws MessagingException {
if (cid == null)
  removeHeader("Content-ID");
else
  setHeader("Content-ID", cid);
}

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

/**
 * Set the "Content-ID" header field of this Message.
 * If the <code>cid</code> parameter is null, any existing 
 * "Content-ID" is removed.
 *
 * @param    cid    the content ID
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
public void setContentID(String cid) throws MessagingException {
if (cid == null)
  removeHeader("Content-ID");
else
  setHeader("Content-ID", cid);
}

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

private void setAddressHeader(String name, Address[] addresses)
    throws MessagingException {
String s = InternetAddress.toString(addresses, name.length() + 2);
if (s == null)
  removeHeader(name);
else
  setHeader(name, s);
}

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

private void addAddressHeader(String name, Address[] addresses)
    throws MessagingException {
if (addresses == null || addresses.length == 0)
  return;
Address[] a = getAddressHeader(name);
Address[] anew;
if (a == null || a.length == 0)
  anew = addresses;
else {
  anew = new Address[a.length + addresses.length];
  System.arraycopy(a, 0, anew, 0, a.length);
  System.arraycopy(addresses, 0, anew, a.length, addresses.length);
}
String s = InternetAddress.toString(anew, name.length() + 2);
if (s == null)
  return;
setHeader(name, s);
}

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

private void setAddressHeader(String name, Address[] addresses)
    throws MessagingException {
String s;
if (allowutf8)
  s = InternetAddress.toUnicodeString(addresses, name.length() + 2);
else
  s = InternetAddress.toString(addresses, name.length() + 2);
if (s == null)
  removeHeader(name);
else
  setHeader(name, s);
}

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

/**
 * Set the RFC 822 "From" header field. Any existing values are 
 * replaced with the given address. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender of this message
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 *            of existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
public void setFrom(Address address) throws MessagingException {
if (address == null)
  removeHeader("From");
else
  setHeader("From", MimeUtility.fold(6, address.toString()));
}

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

/**
 * Set the RFC 822 "Sender" header field. Any existing values are 
 * replaced with the given address. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender of this message
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 *            of existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 * @since        JavaMail 1.3
 */
public void setSender(Address address) throws MessagingException {
if (address == null)
  removeHeader("Sender");
else
  setHeader("Sender", MimeUtility.fold(8, address.toString()));
}

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

/**
 * Set the RFC 822 "From" header field. Any existing values are 
 * replaced with the given address. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender of this message
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 *            of existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 */
@Override
public void setFrom(Address address) throws MessagingException {
if (address == null)
  removeHeader("From");
else
  setHeader("From", MimeUtility.fold(6, address.toString()));
}

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

/**
 * Set the RFC 822 "Sender" header field. Any existing values are 
 * replaced with the given address. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender of this message
 * @exception    IllegalWriteException if the underlying
 *            implementation does not support modification
 *            of existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception    MessagingException for other failures
 * @since        JavaMail 1.3
 */
public void setSender(Address address) throws MessagingException {
if (address == null)
  removeHeader("Sender");
else
  setHeader("Sender", MimeUtility.fold(8, address.toString()));
}

相关文章

MimeMessage类方法