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

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

本文整理了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

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

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

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

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

  1. /**
  2. * Add a recipent of a specified type.
  3. *
  4. * @param type the type of recipient
  5. * @param address the address to add
  6. * @throws MessagingException if there was a problem accessing the store
  7. */
  8. public void addRecipient(RecipientType type, Address address) throws MessagingException {
  9. addRecipients(type, new Address[]{address});
  10. }

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

  1. /**
  2. * Add a recipent of a specified type.
  3. *
  4. * @param type the type of recipient
  5. * @param address the address to add
  6. * @throws MessagingException if there was a problem accessing the Store
  7. */
  8. public void addRecipient(RecipientType type, Address address) throws MessagingException {
  9. addRecipients(type, new Address[]{address});
  10. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception MessagingException
  9. * @exception IllegalWriteException if the underlying
  10. * implementation does not support modification
  11. * of existing values
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception MessagingException
  9. * @exception IllegalWriteException if the underlying
  10. * implementation does not support modification
  11. * of existing values
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. /**
  2. * Add this recipient address to the existing ones of the given type. <p>
  3. *
  4. * The default implementation uses the <code>addRecipients</code> method.
  5. *
  6. * @param type the recipient type
  7. * @param address the address
  8. * @exception IllegalWriteException if the underlying
  9. * implementation does not support modification
  10. * of existing values
  11. * @exception MessagingException for other failures
  12. */
  13. public void addRecipient(RecipientType type, Address address)
  14. throws MessagingException {
  15. Address[] a = new Address[1];
  16. a[0] = address;
  17. addRecipients(type, a);
  18. }

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

  1. @Override
  2. public void addRecipients(RecipientType type, Address[] addresses)
  3. throws RuntimeMessagingException {
  4. try {
  5. delegate.addRecipients(type, addresses);
  6. } catch (MessagingException e) {
  7. throw new RuntimeMessagingException(e);
  8. }
  9. }

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

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

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

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

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

  1. public void notify(String subject, String message) {
  2. if (this.from != null && !this.to.isEmpty()) {
  3. Message msg = new MimeMessage(this.session);
  4. try {
  5. Address[] recipients = this.to.toArray(new Address[this.to.size()]);
  6. Transport transport = this.session.getTransport();
  7. msg.setFrom(this.from);
  8. msg.addRecipients(Message.RecipientType.TO, recipients);
  9. msg.setSubject(subject);
  10. msg.setText(message);
  11. transport.connect();
  12. transport.sendMessage(msg, recipients);
  13. transport.close();
  14. } catch (MessagingException e) {
  15. logger.error("Error while sending notification message '" + subject + "'", e);
  16. }
  17. } else {
  18. logger.warn("From is null or to is empty. Notification won't be send.");
  19. }
  20. }
  21. }

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

  1. private void setMessageHeader(Message msg, SLAEvent event) throws MessagingException {
  2. Address[] from = new InternetAddress[] { fromAddr };
  3. Address[] to;
  4. StringBuilder subject = new StringBuilder();
  5. to = parseAddress(event.getAlertContact());
  6. if (to == null) {
  7. LOG.error("Destination address is null or invalid, stop sending SLA alert email");
  8. throw new IllegalArgumentException("Destination address is not specified properly");
  9. }
  10. subject.append("OOZIE - SLA ");
  11. subject.append(event.getEventStatus().name());
  12. subject.append(" (AppName=");
  13. subject.append(event.getAppName());
  14. subject.append(", JobID=");
  15. subject.append(event.getId());
  16. subject.append(")");
  17. try {
  18. msg.addFrom(from);
  19. msg.addRecipients(RecipientType.TO, to);
  20. msg.setSubject(subject.toString());
  21. }
  22. catch (MessagingException me) {
  23. LOG.error("Message Exception in setting message header of SLA alert email", me);
  24. throw me;
  25. }
  26. }

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

  1. private void setMessageHeader(Message msg, SLAEvent event) throws MessagingException {
  2. Address[] from = new InternetAddress[] { fromAddr };
  3. Address[] to;
  4. StringBuilder subject = new StringBuilder();
  5. to = parseAddress(event.getAlertContact());
  6. if (to == null) {
  7. LOG.error("Destination address is null or invalid, stop sending SLA alert email");
  8. throw new IllegalArgumentException("Destination address is not specified properly");
  9. }
  10. subject.append("OOZIE - SLA ");
  11. subject.append(event.getEventStatus().name());
  12. subject.append(" (AppName=");
  13. subject.append(event.getAppName());
  14. subject.append(", JobID=");
  15. subject.append(event.getId());
  16. subject.append(")");
  17. try {
  18. msg.addFrom(from);
  19. msg.addRecipients(RecipientType.TO, to);
  20. msg.setSubject(subject.toString());
  21. }
  22. catch (MessagingException me) {
  23. LOG.error("Message Exception in setting message header of SLA alert email", me);
  24. throw me;
  25. }
  26. }

相关文章