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

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

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

MimeMessage.addHeader介绍

[英]Add this value to the existing values for this header_name. Note that RFC 822 headers must contain only US-ASCII characters, so a header that contains non US-ASCII characters must have been encoded as per the rules of RFC 2047.
[中]将此值添加到此标题名称的现有值中。请注意,RFC 822标头必须仅包含US-ASCII字符,因此包含非US-ASCII字符的标头必须按照RFC 2047的规则进行编码。

代码示例

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

message.addHeader("Content-type", "text/HTML; charset=UTF-8");
message.addHeader("format", "flowed");
message.addHeader("Content-Transfer-Encoding", "8bit");
message.setSentDate(new Date());
message.setReplyTo(new Address[]{new InternetAddress(senderEmail, displayname)});

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

/**
 * Add the given addresses to the specified recipient type.
 * 
 * @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
 * @since           JavaMail 1.2
 */
public void addRecipients(Message.RecipientType type, String addresses)
              throws MessagingException {
  if (type == RecipientType.NEWSGROUPS) {
    if (addresses != null && addresses.length() != 0)
      addHeader("Newsgroups", addresses);
  } else
    addAddressHeader(getHeaderName(type),
    InternetAddress.parse(addresses));
}

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

/**
 * Add the given addresses to the specified recipient type.
 * 
 * @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
 * @since           JavaMail 1.2
 */
public void addRecipients(Message.RecipientType type, String addresses)
              throws MessagingException {
  if (type == RecipientType.NEWSGROUPS) {
    if (addresses != null && addresses.length() != 0)
      addHeader("Newsgroups", addresses);
  } else
    addAddressHeader(getHeaderName(type),
    InternetAddress.parse(addresses));
}

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

/**
 * Add the given addresses to the specified recipient type.
 *
 * @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
 */
public void addRecipients(Message.RecipientType type, Address[] addresses)
              throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
  String s = NewsAddress.toString(addresses);
  if (s != null)
  addHeader("Newsgroups", s);
} else
  addAddressHeader(getHeaderName(type), addresses);
}

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

/**
 * Add the given addresses to the specified recipient type.
 *
 * @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
 */
@Override
public void addRecipients(Message.RecipientType type, Address[] addresses)
              throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
  String s = NewsAddress.toString(addresses);
  if (s != null)
  addHeader("Newsgroups", s);
} else
  addAddressHeader(getHeaderName(type), addresses);
}

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

this.message.addHeader(entry.getKey(), foldedValue);

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

email.setText(body);
  email.setSentDate(new Date());
  email.addHeader("X-FHIR-Subscription", subscriptionId);
} catch (MessagingException e) {
  throw new InternalErrorException("Failed to create email message", e);

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

/**
 * Add a set of addresses to the existing From header.
 *
 * @param addresses The list to add.
 *
 * @exception MessagingException
 */
public void addFrom(Address[] addresses) throws MessagingException {
  addHeader("From", addresses);
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

/**
 * Add a set of addresses to the existing From header.
 *
 * @param addresses The list to add.
 *
 * @exception MessagingException
 */
public void addFrom(Address[] addresses) throws MessagingException {
  addHeader("From", addresses);
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

/**
 * Add a list of addresses to a target recipient list.
 *
 * @param type    The target recipient type.
 * @param address An array of addresses to add.
 *
 * @exception MessagingException
 */
public void addRecipients(Message.RecipientType type, Address[] address) throws MessagingException {
  addHeader(getHeaderForRecipientType(type), address);
}

代码示例来源:origin: org.apache.james/james-server-core-library

/**
 * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
 */
public void addHeader(String name, String value) throws MessagingException {
  getWrappedMessageForWriting().addHeader(name, value);
}

代码示例来源:origin: org.apache.james/james-server-mailets

private void restoreHeaders(MimeMessage mimeMessage, Map<String, List<String>> savedHeaders) throws MessagingException {
  for (Map.Entry<String, List<String>> header: savedHeaders.entrySet()) {
    String name = header.getKey();
    mimeMessage.removeHeader(name);
    for (String value: header.getValue()) {
      mimeMessage.addHeader(name, value);
    }
  }
}

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

@Override
public void addRequestHeader(String name, String value) throws IOException {
  try {
    requestMessage.addHeader(name, value);
    if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) {
      requestContentType = value;
    }
  }
  catch (MessagingException ex) {
    throw new MailTransportException(ex);
  }
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

/**
 * Add an address to a target recipient list by string name.
 *
 * @param type    The target header type.
 * @param address The address to add.
 *
 * @exception MessagingException
 */
public void addRecipients(Message.RecipientType type, String address) throws MessagingException {
  addHeader(getHeaderForRecipientType(type), address);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail

private void addAddressHeader(String name, Address[] addresses)
    throws MessagingException {
String s = InternetAddress.toString(addresses);
if (s == null)
  return;
addHeader(name, s);
}

代码示例来源:origin: org.mnode.mstor/mstor

/**
 * {@inheritDoc}
 */
public void addHeader(final String s, final String s1)
    throws MessagingException {
  
  super.addHeader(s, s1);
  updateHeaders(false);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public void addRequestHeader(String name, String value) throws IOException {
  try {
    requestMessage.addHeader(name, value);
    if (TransportConstants.HEADER_CONTENT_TYPE.equals(name)) {
      requestContentType = value;
    }
  }
  catch (MessagingException ex) {
    throw new MailTransportException(ex);
  }
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

/**
 * Add a list of addresses to a target recipient list.
 *
 * @param type    The target recipient type.
 * @param address An array of addresses to add.
 *
 * @exception MessagingException
 */
public void addRecipients(Message.RecipientType type, Address[] address) throws MessagingException {
  addHeader(getHeaderForRecipientType(type), address);
}

代码示例来源:origin: org.apache.james/james-server-jmap

private void setJmapMessageIdAsHeader(MimeMessage mimeMessage, MessageId messageId) {
  LOGGER.debug("Adding header {}:{}", X_JAMES_MDN_JMAP_MESSAGE_ID, messageId.serialize());
  try {
    mimeMessage.addHeader(X_JAMES_MDN_JMAP_MESSAGE_ID, messageId.serialize());
  } catch (MessagingException e) {
    LOGGER.error("unable to add " + X_JAMES_MDN_JMAP_MESSAGE_ID + " header to message", e);
  }
}

代码示例来源:origin: org.apache.james/apache-mailet-icalendar

private void addIfPresent(MimeMessage mimeMessage, String headerName, Property property) {
    if (property != null) {
      try {
        mimeMessage.addHeader(headerName, property.getValue());
      } catch (MessagingException e) {
        LOGGER.error("Could not add header {} with value {}", headerName, property.getValue(), e);
      }
    }
  }
}

相关文章

MimeMessage类方法