コード例 #1
0
 /**
  * Convert an e-mail address to a list of MailAddress.
  *
  * @param emailAddress
  *          EmailAddress is a type of <code>microsoft.exchange.webservices.data.property.complex.EmailAddress<code>.
  * @return List&lt;MailAddress&gt;
  */
 protected List<MailAddress> convertToMailAddress(EmailAddress emailAddress) {
   List<MailAddress> addressList = new ArrayList<MailAddress>();
   if (emailAddress != null) {
     MailAddress mailAddress = new MailAddress();
     mailAddress.setAddress(emailAddress.getAddress());
     mailAddress.setName(emailAddress.getName());
     addressList.add(mailAddress);
   }
   return addressList;
 }
コード例 #2
0
 /**
  * Convert an array of addresses to a list of MailAddress.
  *
  * @param addresses
  *          Address is a type of <code>javax.mail.Address<code>.
  * @return List&lt;MailAddress&gt;
  */
 protected List<MailAddress> convertToMailAddress(Address[] addresses) {
   List<MailAddress> addressList = new ArrayList<MailAddress>();
   if ((addresses != null && addresses.length != 0)) {
     if (addresses instanceof InternetAddress[]) {
       InternetAddress[] internetAddresses = (InternetAddress[]) addresses;
       for (InternetAddress internetAddress : internetAddresses) {
         MailAddress mailAddress = new MailAddress();
         String personal = internetAddress.getPersonal();
         String address = internetAddress.getAddress();
         mailAddress.setName(personal);
         mailAddress.setAddress(address);
         addressList.add(mailAddress);
       }
     } else {
       for (Address address : addresses) {
         MailAddress mailAddress = new MailAddress();
         mailAddress.setAddress(address.toString());
         addressList.add(mailAddress);
       }
     }
   }
   return addressList;
 }