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

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

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

Message.addRecipients介绍

[英]Add these recipient addresses to the existing ones of the given type.
[中]将这些收件人地址添加到给定类型的现有收件人地址。

代码示例

代码示例来源:origin: kiegroup/jbpm

if (emailAddress != null) {                        	
  if (toAddresses.add(emailAddress)) {
    msg.addRecipients( Message.RecipientType.TO, InternetAddress.parse( emailAddress, false));

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

代码示例来源:origin: rakam-io/rakam

Message msg = new MimeMessage(session);
msg.setFrom(fromAddress);
msg.addRecipients(MimeMessage.RecipientType.TO, toEmail.stream().map(e -> {
  try {
    return new InternetAddress(e);

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

/**
 * Add a recipent of a specified type.
 *
 * @param type    the type of recipient
 * @param address the address to add
 * @throws MessagingException if there was a problem accessing the store
 */
public void addRecipient(RecipientType type, Address address) throws MessagingException {
  addRecipients(type, new Address[]{address});
}

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

/**
 * Add a recipent of a specified type.
 *
 * @param type    the type of recipient
 * @param address the address to add
 * @throws MessagingException if there was a problem accessing the Store
 */
public void addRecipient(RecipientType type, Address address) throws MessagingException {
  addRecipients(type, new Address[]{address});
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception       MessagingException
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception       MessagingException
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

代码示例来源:origin: org.glassfish.metro/webservices-extra

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

代码示例来源:origin: jboss/jboss-javaee-specs

/**
 * Add this recipient address to the existing ones of the given type. <p>
 *
 * The default implementation uses the <code>addRecipients</code> method.
 *
 * @param type      the recipient type
 * @param address    the address
 * @exception    IllegalWriteException if the underlying 
 *            implementation does not support modification 
 *            of existing values
 * @exception       MessagingException for other failures
 */
public void addRecipient(RecipientType type, Address address)
              throws MessagingException {
Address[] a = new Address[1];
a[0] = address;
addRecipients(type, a);
}

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

@Override
public void addRecipients(RecipientType type, Address[] addresses)
  throws RuntimeMessagingException {
 try {
  delegate.addRecipients(type, addresses);
 } catch (MessagingException e) {
  throw new RuntimeMessagingException(e);
 }
}

代码示例来源:origin: com.threewks.thundr/thundr

private void addRecipients(Map<String, String> to, Message message, RecipientType recipientType) throws MessagingException {
  if (Expressive.isNotEmpty(to)) {
    List<Address> addresses = new ArrayList<>();
    for (Entry<String, String> recipient : to.entrySet()) {
      addresses.add(emailAddress(recipient));
    }
    message.addRecipients(recipientType, addresses.toArray(new Address[0]));
  }
}

代码示例来源:origin: 3wks/thundr

private void addRecipients(Map<String, String> to, Message message, RecipientType recipientType) throws MessagingException {
  if (Expressive.isNotEmpty(to)) {
    List<Address> addresses = new ArrayList<>();
    for (Entry<String, String> recipient : to.entrySet()) {
      addresses.add(emailAddress(recipient));
    }
    message.addRecipients(recipientType, addresses.toArray(new Address[0]));
  }
}

代码示例来源:origin: Spirals-Team/repairnator

public void notify(String subject, String message) {
    if (this.from != null && !this.to.isEmpty()) {
      Message msg = new MimeMessage(this.session);

      try {
        Address[] recipients = this.to.toArray(new Address[this.to.size()]);
        Transport transport = this.session.getTransport();
        
        msg.setFrom(this.from);
        msg.addRecipients(Message.RecipientType.TO, recipients);
        msg.setSubject(subject);
        msg.setText(message);
        
        transport.connect();
        transport.sendMessage(msg, recipients);
        transport.close();
      } catch (MessagingException e) {
        logger.error("Error while sending notification message '" + subject + "'", e);
      }
    } else {
      logger.warn("From is null or to is empty. Notification won't be send.");
    }

  }
}

代码示例来源:origin: apache/oozie

private void setMessageHeader(Message msg, SLAEvent event) throws MessagingException {
  Address[] from = new InternetAddress[] { fromAddr };
  Address[] to;
  StringBuilder subject = new StringBuilder();
  to = parseAddress(event.getAlertContact());
  if (to == null) {
    LOG.error("Destination address is null or invalid, stop sending SLA alert email");
    throw new IllegalArgumentException("Destination address is not specified properly");
  }
  subject.append("OOZIE - SLA ");
  subject.append(event.getEventStatus().name());
  subject.append(" (AppName=");
  subject.append(event.getAppName());
  subject.append(", JobID=");
  subject.append(event.getId());
  subject.append(")");
  try {
    msg.addFrom(from);
    msg.addRecipients(RecipientType.TO, to);
    msg.setSubject(subject.toString());
  }
  catch (MessagingException me) {
    LOG.error("Message Exception in setting message header of SLA alert email", me);
    throw me;
  }
}

代码示例来源:origin: org.apache.oozie/oozie-core

private void setMessageHeader(Message msg, SLAEvent event) throws MessagingException {
  Address[] from = new InternetAddress[] { fromAddr };
  Address[] to;
  StringBuilder subject = new StringBuilder();
  to = parseAddress(event.getAlertContact());
  if (to == null) {
    LOG.error("Destination address is null or invalid, stop sending SLA alert email");
    throw new IllegalArgumentException("Destination address is not specified properly");
  }
  subject.append("OOZIE - SLA ");
  subject.append(event.getEventStatus().name());
  subject.append(" (AppName=");
  subject.append(event.getAppName());
  subject.append(", JobID=");
  subject.append(event.getId());
  subject.append(")");
  try {
    msg.addFrom(from);
    msg.addRecipients(RecipientType.TO, to);
    msg.setSubject(subject.toString());
  }
  catch (MessagingException me) {
    LOG.error("Message Exception in setting message header of SLA alert email", me);
    throw me;
  }
}

相关文章

微信公众号

最新文章

更多