本文整理了Java中javax.mail.Message.setHeader()
方法的一些代码示例,展示了Message.setHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setHeader()
方法的具体详情如下:
包路径:javax.mail.Message
类名称:Message
方法名:setHeader
暂无
代码示例来源:origin: apache/nifi
private void setMessageHeader(final String header, final String value, final Message message) throws MessagingException {
final ComponentLog logger = getLogger();
try {
message.setHeader(header, MimeUtility.encodeText(value));
} catch (UnsupportedEncodingException e){
logger.warn("Unable to add header {} with value {} due to encoding exception", new Object[]{header, value});
}
}
代码示例来源:origin: javamelody/javamelody
msg.setFrom(fromAddress);
if (highPriority) {
msg.setHeader("X-Priority", "1");
msg.setHeader("x-msmail-priority", "high");
代码示例来源:origin: pentaho/pentaho-kettle
msg.setHeader( "X-Priority", priority_int ); // (String)int between 1= high and 3 = low.
msg.setHeader( "Importance", meta.getImportance() );
msg.setHeader( "Sensitivity", meta.getSensitivity() );
代码示例来源:origin: kiegroup/jbpm
msg.setHeader( "X-Mailer", "jbpm human task service" );
msg.setSentDate( new Date() );
代码示例来源:origin: pentaho/pentaho-kettle
msg.setHeader( "X-Priority", priority_int ); // (String)int between 1= high and 3 = low.
msg.setHeader( "Importance", importance );
msg.setHeader( "Sensitivity", sensitivity );
代码示例来源: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: camunda/camunda-bpm-platform
/**
* Sets the priority and importance headers.
* @param msg the target message.
*/
private void setPriority(final Message msg) {
try {
msg.setHeader("Importance", "High");
msg.setHeader("Priority", "urgent");
msg.setHeader("X-Priority", "2"); //High
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Sets the priority and importance headers.
* @param msg the target message.
*/
private void setPriority(final Message msg) {
try {
msg.setHeader("Importance", "High");
msg.setHeader("Priority", "urgent");
msg.setHeader("X-Priority", "2"); //High
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Used to signal that body parts are missing from a message. Also used
* when LogRecords were passed to an attachment formatter but the formatter
* produced no output, which is allowed. Used during a verify because all
* parts are omitted, none of the content formatters are used. This is
* not used when a filter prevents LogRecords from being formatted.
* This header is defined in RFC 2156 and RFC 4021.
* @param msg the message.
* @since JavaMail 1.4.5
*/
private void setIncompleteCopy(final Message msg) {
try {
msg.setHeader("Incomplete-Copy", "");
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Used to signal that body parts are missing from a message. Also used
* when LogRecords were passed to an attachment formatter but the formatter
* produced no output, which is allowed. Used during a verify because all
* parts are omitted, none of the content formatters are used. This is
* not used when a filter prevents LogRecords from being formatted.
* This header is defined in RFC 2156 and RFC 4021.
* @param msg the message.
* @since JavaMail 1.4.5
*/
private void setIncompleteCopy(final Message msg) {
try {
msg.setHeader("Incomplete-Copy", "");
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Sets the x-mailer header.
* @param msg the target message.
*/
private void setMailer(final Message msg) {
try {
final Class<?> mail = MailHandler.class;
final Class<?> k = getClass();
String value;
if (k == mail) {
value = mail.getName();
} else {
try {
value = MimeUtility.encodeText(k.getName());
} catch (final UnsupportedEncodingException E) {
reportError(E.getMessage(), E, ErrorManager.FORMAT_FAILURE);
value = k.getName().replaceAll("[^\\x00-\\x7F]", "\uu001A");
}
value = MimeUtility.fold(10, mail.getName() + " using the "
+ value + " extension.");
}
msg.setHeader("X-Mailer", value);
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Sets the x-mailer header.
* @param msg the target message.
*/
private void setMailer(final Message msg) {
try {
final Class<?> mail = MailHandler.class;
final Class<?> k = getClass();
String value;
if (k == mail) {
value = mail.getName();
} else {
try {
value = MimeUtility.encodeText(k.getName());
} catch (final UnsupportedEncodingException E) {
reportError(E.getMessage(), E, ErrorManager.FORMAT_FAILURE);
value = k.getName().replaceAll("[^\\x00-\\x7F]", "\uu001A");
}
value = MimeUtility.fold(10, mail.getName() + " using the "
+ value + " extension.");
}
msg.setHeader("X-Mailer", value);
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Signals that this message was generated by automatic process.
* This header is defined in RFC 3834 section 5.
* @param msg the message.
* @since JavaMail 1.4.6
*/
private void setAutoSubmitted(final Message msg) {
if (allowRestrictedHeaders()) {
try { //RFC 3834 (5.2)
msg.setHeader("auto-submitted", "auto-generated");
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Signals that this message was generated by automatic process.
* This header is defined in RFC 3834 section 5.
* @param msg the message.
* @since JavaMail 1.4.6
*/
private void setAutoSubmitted(final Message msg) {
if (allowRestrictedHeaders()) {
try { //RFC 3834 (5.2)
msg.setHeader("auto-submitted", "auto-generated");
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: com.sun.mail/javax.mail
String cte = "Content-Transfer-Encoding";
if (abort.getHeader(cte) == null) {
abort.setHeader(cte, "base64");
abort.saveChanges();
} else {
代码示例来源:origin: javax.mail/com.springsource.javax.mail
private void setPriority(final Message msg) {
try {
msg.setHeader("Importance", "High");
msg.setHeader("Priority", "urgent");
msg.setHeader("X-Priority", "2"); //High
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
代码示例来源:origin: com.adaptrex/adaptrex-plus
public Message createMessage() {
try {
Message msg = new MimeMessage(getSession());
msg.setHeader("X-Mailer", "Adaptrex Mailer");
return msg;
} catch (Exception e) {
// log.warn("Error", e);
return null;
}
}
}
代码示例来源:origin: google/mail-importer
@Override
public void setHeader(String header_name, String header_value)
throws RuntimeMessagingException {
try {
delegate.setHeader(header_name, header_value);
} catch (MessagingException e) {
throw new RuntimeMessagingException(e);
}
}
代码示例来源:origin: org.evolvis.bsi/kolab-ws
public static void
IMAPMessage_setHeader(Message message, String name, String value)
throws MessagingException
{
if (!Profiler.INSTANCE.isActive()) // only needed for better performance
message.setHeader(name, value);
else
profileInvokeMExcep(message, "setHeader", name, value);
}
代码示例来源:origin: org.apache.nifi/nifi-standard-processors
private void setMessageHeader(final String header, final String value, final Message message) throws MessagingException {
final ComponentLog logger = getLogger();
try {
message.setHeader(header, MimeUtility.encodeText(value));
} catch (UnsupportedEncodingException e){
logger.warn("Unable to add header {} with value {} due to encoding exception", new Object[]{header, value});
}
}
内容来源于网络,如有侵权,请联系作者删除!