@Test public void testXOriginalTo() throws Exception { Address[] addresses = {new Address("test2@mail.com")}; msg.setRecipients(Message.RecipientType.X_ORIGINAL_TO, addresses); Identity identity = IdentityHelper.getRecipientIdentityFromMessage(account, msg); assertTrue(identity.getEmail().equalsIgnoreCase("test2@mail.com")); }
public static Identity getRecipientIdentityFromMessage(Account account, Message message) { Identity recipient = null; for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC); if (ccAddresses.length > 0) { for (Address address : ccAddresses) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } } if (recipient == null) { recipient = account.getIdentity(0); } return recipient; }
IdentityHelper { public static Identity getRecipientIdentityFromMessage(Account account, Message message) { Identity recipient = null; for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC); if (ccAddresses.length > 0) { for (Address address : ccAddresses) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } } if (recipient == null) { recipient = account.getIdentity(0); } return recipient; } }
IdentityHelper { public static Identity getRecipientIdentityFromMessage(Account account, Message message) { Identity recipient = null; for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC); if (ccAddresses.length > 0) { for (Address address : ccAddresses) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } } if (recipient == null) { recipient = account.getIdentity(0); } return recipient; }  }
IdentityHelper { public static Identity getRecipientIdentityFromMessage(Account account, Message message) { Identity recipient = null; for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC); if (ccAddresses.length > 0) { for (Address address : ccAddresses) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } } if (recipient == null) { recipient = account.getIdentity(0); } return recipient; }  static Identity getRecipientIdentityFromMessage(Account account, Message message); }
IdentityHelper { public static Identity getRecipientIdentityFromMessage(Account account, Message message) { Identity recipient = null; for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { for (Address address : message.getRecipients(Message.RecipientType.TO)) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } if (recipient == null) { Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC); if (ccAddresses.length > 0) { for (Address address : ccAddresses) { Identity identity = account.findIdentity(address); if (identity != null) { recipient = identity; break; } } } } if (recipient == null) { recipient = account.getIdentity(0); } return recipient; }  static Identity getRecipientIdentityFromMessage(Account account, Message message);  }