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

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

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

Message.addHeader介绍

暂无

代码示例

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

msg.addHeader( "MyHeaderName", "myHeaderValue" );

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

msg.addHeader( "MyHeaderName", "myHeaderValue" );

代码示例来源:origin: net.anotheria/ano-comm

/**
 * Called by extending class to set headers in the message after transformation.
 * 
 * @param msg
 * @throws MessagingException
 */
protected void addHeadersToMessage(Message msg) throws MessagingException {
  Collection<String> allHeaders = headers.keySet();
  for (String key : allHeaders) {
    String val = headers.get(key);
    msg.addHeader(key, val);
  }
}

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

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

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

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

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

@Override
public void addHeader(String header_name, String header_value)
  throws RuntimeMessagingException {
 try {
  delegate.addHeader(header_name, header_value);
 } catch (MessagingException e) {
  throw new RuntimeMessagingException(e);
 }
}

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

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

代码示例来源:origin: org.codemonkey.simplejavamail/simple-java-mail

/**
 * Sets all headers on the {@link Message} instance. Since we're not using a high-level JavaMail method, the JavaMail library says we need to do some
 * encoding and 'folding' manually, to get the value right for the headers (see {@link MimeUtility}.
 *
 * @param email   The message in which the headers are defined.
 * @param message The {@link Message} on which to set the raw, encoded and folded headers.
 * @throws UnsupportedEncodingException See {@link MimeUtility#encodeText(String, String, String)}
 * @throws MessagingException           See {@link Message#addHeader(String, String)}
 * @see MimeUtility#encodeText(String, String, String)
 * @see MimeUtility#fold(int, String)
 */
private static void setHeaders(final Email email, final Message message)
    throws UnsupportedEncodingException, MessagingException {
  // add headers (for raw message headers we need to 'fold' them using MimeUtility
  for (Map.Entry<String, String> header : email.getHeaders().entrySet()) {
    String headerName = header.getKey();
    String headerValue = MimeUtility.encodeText(header.getValue(), CHARACTER_ENCODING, null);
    String foldedHeaderValue = MimeUtility.fold(headerName.length() + 2, headerValue);
    message.addHeader(header.getKey(), foldedHeaderValue);
  }
}

代码示例来源:origin: com.aliyun/aliyun-java-sdk-dm

private void setHeader(Email email, Message message) throws UnsupportedEncodingException, MessagingException {
    if(email.getTemplateContent() != null && email.getTemplateContent().length() > 0) {
      email.getHeaders().put(X_SMTP_TRANS_PARAM, email.getTemplateContent());
    }
    for(Map.Entry<String, String> header : email.getHeaders().entrySet()) {
      String name = header.getKey();
      String value = MimeUtility.encodeText(header.getValue(), EMAIL_ENCODING, null);
      String foldedHeaderValue = MimeUtility.fold(name.length() + 2, value);
      message.addHeader(header.getKey(), foldedHeaderValue);
    }
  }
}

代码示例来源:origin: keeps/roda

public void sendMail(String recipient, String message) throws MessagingException {
 if ("".equals(from)) {
  throw new MessagingException();
 }
 Session session = Session.getDefaultInstance(props, authenticator);
 session.setDebug(false);
 Message msg = new MimeMessage(session);
 InternetAddress addressFrom = new InternetAddress(from);
 msg.setFrom(addressFrom);
 msg.addHeader("name", fromActor);
 msg.setSubject(subject);
 InternetAddress recipientAddress = new InternetAddress(recipient);
 msg.setRecipient(Message.RecipientType.TO, recipientAddress);
 String htmlMessage = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%s", message);
 MimeMultipart mimeMultipart = new MimeMultipart();
 MimeBodyPart mimeBodyPart = new MimeBodyPart();
 mimeBodyPart.setContent(htmlMessage, "text/html;charset=UTF-8");
 mimeMultipart.addBodyPart(mimeBodyPart);
 msg.setContent(mimeMultipart);
 // sending the message
 SMTPTransport transport = (SMTPTransport) session.getTransport(this.protocol);
 transport.connect();
 transport.sendMessage(msg, msg.getAllRecipients());
 transport.close();
}

代码示例来源:origin: com.bbossgroups.pdp/pdp-system

mimeMsg.setRecipients(Message.RecipientType.TO, to);
mimeMsg.setSubject(subject);
mimeMsg.addHeader("Disposition-Notification-To","0");
mimeMsg.setSentDate(new Date());

代码示例来源:origin: org.simplejavamail/simple-java-mail

final String headerValue = MimeUtility.encodeText(header.getValue(), CHARACTER_ENCODING, null);
final String foldedHeaderValue = MimeUtility.fold(headerName.length() + 2, headerValue);
message.addHeader(header.getKey(), foldedHeaderValue);

代码示例来源:origin: juandesi/email4j

m.addHeader(entry.getKey(), entry.getValue());

相关文章