本文整理了Java中javax.mail.Message.setReplyTo()
方法的一些代码示例,展示了Message.setReplyTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setReplyTo()
方法的具体详情如下:
包路径:javax.mail.Message
类名称:Message
方法名:setReplyTo
[英]Set the addresses to which replies should be directed. (Normally only a single address will be specified.) Not all message types allow this to be specified separately from the sender of the message.
The default implementation provided here just throws the MethodNotSupportedException.
[中]设置回复应指向的地址。(通常只指定一个地址。)并非所有邮件类型都允许将其与邮件的发件人分开指定。
这里提供的默认实现只是抛出MethodNotSupportedException。
代码示例来源:origin: log4j/log4j
/**
* Address message.
* @param msg message, may not be null.
* @throws MessagingException thrown if error addressing message.
* @since 1.2.14
*/
protected void addressMessage(final Message msg) throws MessagingException {
if (from != null) {
msg.setFrom(getAddress(from));
} else {
msg.setFrom();
}
//Add ReplyTo addresses if defined.
if (replyTo != null && replyTo.length() > 0) {
msg.setReplyTo(parseAddress(replyTo));
}
if (to != null && to.length() > 0) {
msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
}
//Add CC receipients if defined.
if (cc != null && cc.length() > 0) {
msg.setRecipients(Message.RecipientType.CC, parseAddress(cc));
}
//Add BCC receipients if defined.
if (bcc != null && bcc.length() > 0) {
msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc));
}
}
代码示例来源:origin: pentaho/pentaho-kettle
msg.setReplyTo( address );
代码示例来源:origin: kiegroup/jbpm
User user = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user).setId(header.getReplyTo());
msg.setReplyTo( new InternetAddress[] {
new InternetAddress(userInfo.getEmailForEntity(user))});
} else if (mailSession.getProperty("mail.replyto") != null) {
msg.setReplyTo( new InternetAddress[] { new InternetAddress(mailSession.getProperty("mail.replyto"))});
代码示例来源:origin: pentaho/pentaho-kettle
address[i] = new InternetAddress( reply_Address_List[i] );
msg.setReplyTo( address );
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: apache/log4j
/**
* Address message.
* @param msg message, may not be null.
* @throws MessagingException thrown if error addressing message.
* @since 1.2.14
*/
protected void addressMessage(final Message msg) throws MessagingException {
if (from != null) {
msg.setFrom(getAddress(from));
} else {
msg.setFrom();
}
//Add ReplyTo addresses if defined.
if (replyTo != null && replyTo.length() > 0) {
msg.setReplyTo(parseAddress(replyTo));
}
if (to != null && to.length() > 0) {
msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
}
//Add CC receipients if defined.
if (cc != null && cc.length() > 0) {
msg.setRecipients(Message.RecipientType.CC, parseAddress(cc));
}
//Add BCC receipients if defined.
if (bcc != null && bcc.length() > 0) {
msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc));
}
}
代码示例来源:origin: google/mail-importer
@Override
public void setReplyTo(Address[] addresses) throws RuntimeMessagingException {
try {
delegate.setReplyTo(addresses);
} catch (MessagingException e) {
throw new RuntimeMessagingException(e);
}
}
代码示例来源:origin: javax.mail/com.springsource.javax.mail
private void setReplyTo(final Message msg, final Properties props) {
final String reply = props.getProperty("mail.reply.to");
if (reply != null && reply.length() > 0) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address != null && address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: stackoverflow.com
public String sendMail(String from, String to, String replyTo, String subject, String message) {
String output=null;
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from, "Gmail.com Admin"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress(to, "Mr. User"));
msg.setSubject(subject);
msg.setText(message);
msg.setReplyTo(new InternetAddress[]{new InternetAddress(replyTo)});
Transport.send(msg);
} catch (Exception e) {
output=e.toString();
}
return output;
}
代码示例来源:origin: org.codemonkey.simplejavamail/simple-java-mail
/**
* Fills the {@link Message} instance with reply-to address.
*
* @param email The message in which the recipients are defined.
* @param message The javax message that needs to be filled with reply-to address.
* @throws UnsupportedEncodingException See {@link InternetAddress#InternetAddress(String, String)}.
* @throws MessagingException See {@link Message#setReplyTo(Address[])}
*/
private static void setReplyTo(final Email email, final Message message)
throws UnsupportedEncodingException, MessagingException {
final Recipient replyToRecipient = email.getReplyToRecipient();
if (replyToRecipient != null) {
InternetAddress replyToAddress = new InternetAddress(replyToRecipient.getAddress(), replyToRecipient.getName(), CHARACTER_ENCODING);
message.setReplyTo(new Address[] { replyToAddress });
}
}
代码示例来源:origin: aseldawy/spatialhadoop2
private void sendFailureEmail(Exception e) throws AddressException, MessagingException, UnsupportedEncodingException {
Properties props = new Properties(MAIL_PROPERTIES);
Session mailSession = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
Message message = new MimeMessage(mailSession);
InternetAddress requesterAddress = new InternetAddress(email, requesterName);
message.setFrom(new InternetAddress(from, "SHAHED Team"));
message.addRecipient(RecipientType.TO, requesterAddress);
InternetAddress adminAddress = new InternetAddress("eldawy@cs.umn.edu", "Ahmed Eldawy");
message.addRecipient(RecipientType.BCC, adminAddress);
message.setSubject("Confirmation: Your request has failed");
message.setText("Dear "+requesterName+",\n"+
"Unfortunately there was an internal error while processing your request.\n"+
e.getMessage() + "\n" +
"Sorry for inconvenience. \n\n Shahed team");
message.setReplyTo(new InternetAddress[] {new InternetAddress(from, "SHAHED Team")});
Transport.send(message, message.getAllRecipients());
LOG.info("Message sent successfully to '"+requesterAddress+"'");
}
代码示例来源:origin: org.simplejavamail/simple-java-mail
/**
* Fills the {@link Message} instance with reply-to address.
*
* @param email The message in which the recipients are defined.
* @param message The javax message that needs to be filled with reply-to address.
* @throws UnsupportedEncodingException See {@link InternetAddress#InternetAddress(String, String)}.
* @throws MessagingException See {@link Message#setReplyTo(Address[])}
*/
private static void setReplyTo(final Email email, final Message message)
throws UnsupportedEncodingException, MessagingException {
final Recipient replyToRecipient = email.getReplyToRecipient();
if (replyToRecipient != null) {
final InternetAddress replyToAddress = new InternetAddress(replyToRecipient.getAddress(), replyToRecipient.getName(),
CHARACTER_ENCODING);
message.setReplyTo(new Address[] { replyToAddress });
}
}
代码示例来源:origin: com.sun.mail/android-mail
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: org.glassfish.metro/webservices-extra
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: com.sun.mail/jakarta.mail
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: jboss/jboss-javaee-specs
/**
* Sets reply-to address header.
* @param msg the target message.
*/
private void setReplyTo(final Message msg) {
final String reply = getSession(msg).getProperty("mail.reply.to");
if (!isEmpty(reply)) {
try {
final Address[] address = InternetAddress.parse(reply, false);
if (address.length > 0) {
msg.setReplyTo(address);
}
} catch (final MessagingException ME) {
reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE);
}
}
}
代码示例来源:origin: org.xbib.malva/malva
public void send(String subject,
Address from, Address[] replyTo,
Address[] to, Address[] cc, Address[] bcc,
Multipart multipart) throws Exception {
WithContext<Object> action = ctx -> {
Message message = new MimeMessage(ctx.session);
message.setSentDate(new Date());
message.setFrom(from);
message.setSubject(subject);
if (replyTo != null) {
message.setReplyTo(replyTo);
}
message.setRecipients(Message.RecipientType.TO, to);
if (cc != null) {
message.setRecipients(Message.RecipientType.CC, cc);
}
if (bcc != null) {
message.setRecipients(Message.RecipientType.BCC, bcc);
}
message.setContent(multipart);
Transport.send(message);
return null;
};
performWithContext(action);
}
代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j
/**
* Address message.
* @param msg message, may not be null.
* @throws MessagingException thrown if error addressing message.
* @since 1.2.14
*/
protected void addressMessage(final Message msg) throws MessagingException {
if (from != null) {
msg.setFrom(getAddress(from));
} else {
msg.setFrom();
}
//Add ReplyTo addresses if defined.
if (replyTo != null && replyTo.length() > 0) {
msg.setReplyTo(parseAddress(replyTo));
}
if (to != null && to.length() > 0) {
msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
}
//Add CC receipients if defined.
if (cc != null && cc.length() > 0) {
msg.setRecipients(Message.RecipientType.CC, parseAddress(cc));
}
//Add BCC receipients if defined.
if (bcc != null && bcc.length() > 0) {
msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc));
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Address message.
* @param msg message, may not be null.
* @throws MessagingException thrown if error addressing message.
* @since 1.2.14
*/
protected void addressMessage(final Message msg) throws MessagingException {
if (from != null) {
msg.setFrom(getAddress(from));
} else {
msg.setFrom();
}
//Add ReplyTo addresses if defined.
if (replyTo != null && replyTo.length() > 0) {
msg.setReplyTo(parseAddress(replyTo));
}
if (to != null && to.length() > 0) {
msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
}
//Add CC receipients if defined.
if (cc != null && cc.length() > 0) {
msg.setRecipients(Message.RecipientType.CC, parseAddress(cc));
}
//Add BCC receipients if defined.
if (bcc != null && bcc.length() > 0) {
msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc));
}
}
内容来源于网络,如有侵权,请联系作者删除!