Example #1
0
 public static Set<EmailRecipient> getRecipients(Message.RecipientType type, Message message)
     throws MessagingException {
   HashSet<EmailRecipient> out = new HashSet<EmailRecipient>();
   try {
     if (message.getRecipients(type) != null) {
       for (Address recipient : message.getAllRecipients()) {
         String name = "";
         String address = "";
         if (recipient instanceof InternetAddress) {
           if (((InternetAddress) recipient).getPersonal() != null) {
             name = ((InternetAddress) recipient).getPersonal();
           }
           if (((InternetAddress) recipient).getAddress() != null) {
             address = ((InternetAddress) recipient).getAddress();
           }
           RecipientType newType = RecipientType.TO;
           if (type.equals(Message.RecipientType.CC)) {
             newType = RecipientType.CC;
           } else if (type.equals(Message.RecipientType.BCC)) {
             newType = RecipientType.BCC;
           }
           out.add(new EmailRecipient(address, name, newType));
         }
       }
     }
   } catch (AddressException ex) {
     // Do nothing - illegal formatting in recipient field
   }
   return out;
 }
Example #2
0
  public boolean equals(Object var1) {
    boolean var4;
    if (var1 instanceof RecipientStringTerm) {
      Message.RecipientType var2 = ((RecipientStringTerm) var1).type;
      Message.RecipientType var3 = this.type;
      if (var2.equals(var3) && super.equals(var1)) {
        var4 = true;
        return var4;
      }
    }

    var4 = false;
    return var4;
  }