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

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

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

MimeMessage.removeHeader介绍

[英]Remove all headers with this name.
[中]删除所有具有此名称的标题。

代码示例

代码示例来源: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

/**
 * Set the RFC 822 "From" header field. Any existing values are 
 * replaced with the given addresses. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender(s) 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        JvaMail 1.5
 */
public void setFrom(String address) throws MessagingException {
if (address == null)
  removeHeader("From");
else
  setAddressHeader("From", InternetAddress.parse(address));
}

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

/**
 * Set the RFC 822 "From" header field. Any existing values are 
 * replaced with the given addresses. If address is <code>null</code>,
 * this header is removed.
 *
 * @param address    the sender(s) 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        JvaMail 1.5
 */
public void setFrom(String address) throws MessagingException {
if (address == null)
  removeHeader("From");
else
  setAddressHeader("From", InternetAddress.parse(address));
}

代码示例来源: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: 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 "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 
 * <code>null</code>, the existing "Date" field is removed.
 *
 * @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 setSentDate(Date d) throws MessagingException {
if (d == null)
  removeHeader("Date");
else {
  synchronized (mailDateFormat) {
  setHeader("Date", mailDateFormat.format(d));
  }
}
}

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

/**
 * 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 
 * <code>null</code>, the existing "Date" field is removed.
 *
 * @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 setSentDate(Date d) throws MessagingException {
if (d == null)
  removeHeader("Date");
else {
  synchronized (mailDateFormat) {
  setHeader("Date", mailDateFormat.format(d));
  }
}
}

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

/**
 * Set the specified recipient type to the given addresses.
 * If the address parameter is <code>null</code>, the corresponding
 * recipient field is removed.
 *   
 * @param type      Recipient type
 * @param addresses Addresses
 * @exception       AddressException if the attempt to parse the
 *                  addresses String fails
 * @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
 * @see             #getRecipients
 * @since           JavaMail 1.2
 */
public void setRecipients(Message.RecipientType type, String addresses)
              throws MessagingException {
  if (type == RecipientType.NEWSGROUPS) {
    if (addresses == null || addresses.length() == 0)
      removeHeader("Newsgroups");
    else
      setHeader("Newsgroups", addresses);
  } else
    setAddressHeader(getHeaderName(type),
  addresses == null ? null : InternetAddress.parse(addresses));
}

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

/**
 * Set the specified recipient type to the given addresses.
 * If the address parameter is <code>null</code>, the corresponding
 * recipient field is removed.
 *   
 * @param type      Recipient type
 * @param addresses Addresses
 * @exception       AddressException if the attempt to parse the
 *                  addresses String fails
 * @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
 * @see             #getRecipients
 * @since           JavaMail 1.2
 */
public void setRecipients(Message.RecipientType type, String addresses)
              throws MessagingException {
  if (type == RecipientType.NEWSGROUPS) {
    if (addresses == null || addresses.length() == 0)
      removeHeader("Newsgroups");
    else
      setHeader("Newsgroups", addresses);
  } else
    setAddressHeader(getHeaderName(type),
  addresses == null ? null : InternetAddress.parse(addresses));
}

代码示例来源: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()));
}

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

/**
 * Set the specified recipient type to the given addresses.
 * If the address parameter is <code>null</code>, the corresponding
 * recipient field is removed.
 *
 * @param type    Recipient type
 * @param addresses    Addresses
 * @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
 * @see        #getRecipients
 */
public void setRecipients(Message.RecipientType type, Address[] addresses)
              throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
  if (addresses == null || addresses.length == 0)
  removeHeader("Newsgroups");
  else
  setHeader("Newsgroups", NewsAddress.toString(addresses));
} else
  setAddressHeader(getHeaderName(type), addresses);
}

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

/**
 * Set the specified recipient type to the given addresses.
 * If the address parameter is <code>null</code>, the corresponding
 * recipient field is removed.
 *
 * @param type    Recipient type
 * @param addresses    Addresses
 * @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
 * @see        #getRecipients
 */
@Override
public void setRecipients(Message.RecipientType type, Address[] addresses)
              throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
  if (addresses == null || addresses.length == 0)
  removeHeader("Newsgroups");
  else
  setHeader("Newsgroups", NewsAddress.toString(addresses));
} else
  setAddressHeader(getHeaderName(type), addresses);
}

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

throws MessagingException {
if (subject == null) {
  removeHeader("Subject");
} else {
  try {

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

throws MessagingException {
if (subject == null) {
  removeHeader("Subject");
} else {
  try {

代码示例来源:origin: javax.mail/javax.mail-api

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: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

public void setDescription(String description, String charset) throws MessagingException {
  if (description == null) {
    removeHeader("Content-Description");
  }
  else {
    try {
      setHeader("Content-Description", ASCIIUtil.fold(21, MimeUtility.encodeText(description, charset, null)));
    } catch (UnsupportedEncodingException e) {
      throw new MessagingException(e.getMessage(), e);
    }
  }
}

相关文章

MimeMessage类方法