none
TRICKY SCENARIO: Counting Recipients: Count unique recipients when item includes nested distribution lists? RRS feed

  • Question

  • Any help is greatly appreciated.

    Goal: Count the UNIQUE number of people on an email or meeting when the item includes nested distribution lists.

    Scenario #1:

    • Sender is bob@domain.com
    • Recipient list includes the distribution list ‘Managers’,
    • 'Managers’ distribution list includes the distribution list ‘IT Managers’, 'Marketing Managers',
    • 'IT Managers’ distribution list includes bob@domain.com
    • bob also included bob@domain.com himself as an optional attendee

    How do I ensure bob@domain.com is counted only once?

    Monday, June 2, 2014 3:53 AM

Answers

  • Hello Mike,

    You need to iterate over all recipients in the collection and find entries with the specified email (bob@domain.com). You can use the AddressEntry property of the Recipient class for getting a corresponding object which holds information that represents a person, group, or public folder to which the messaging system can deliver messages. Then get a distribution list if any and iterate over all emails there.

    Monday, June 2, 2014 9:09 AM
  • For a distribution list get it as a DistListItem object and use the MemberCount property and GetMember() method to get each member of the DL. Check each member as you retrieve it and see it it's a nested DL or not.


    Ken Slovak MVP - Outlook

    Monday, June 2, 2014 3:05 PM
    Moderator
  • Add each recipient to a collection or list. use the email address as the key. Check for existing keys that match a new key when you try to add it. If it exists in the collection don't add it. At the end of iterating the recipients you'd end up with a collection of unique recipients.

    Ken Slovak MVP - Outlook

    • Marked as answer by Mike Bannen Tuesday, June 10, 2014 5:20 AM
    Monday, June 9, 2014 1:43 PM
    Moderator
  • For your second question, there are cases of nested DL's where at some point you can't get member addresses. So don't use nested DL's if possible.

    Also, if Exchange is being used Recipient.Address will return an Exchange DN and not an SMTP email address. In those cases you can use Recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress to retrieve the SMTP address.


    Ken Slovak MVP - Outlook

    • Marked as answer by Mike Bannen Monday, June 16, 2014 12:28 AM
    Tuesday, June 10, 2014 1:55 PM
    Moderator

All replies

  • Hello Mike,

    You need to iterate over all recipients in the collection and find entries with the specified email (bob@domain.com). You can use the AddressEntry property of the Recipient class for getting a corresponding object which holds information that represents a person, group, or public folder to which the messaging system can deliver messages. Then get a distribution list if any and iterate over all emails there.

    Monday, June 2, 2014 9:09 AM
  • For a distribution list get it as a DistListItem object and use the MemberCount property and GetMember() method to get each member of the DL. Check each member as you retrieve it and see it it's a nested DL or not.


    Ken Slovak MVP - Outlook

    Monday, June 2, 2014 3:05 PM
    Moderator
  • Thanks everyone for replies. I'm not sure the replies address the exact issue.

    I'm trying to determine how many unique, physical people plan to attend (or have attended) based on their response status). 

    A single person could be

    - on multiple distribution lists

    - entered as an individual 

    - also could be the organizer

    And the end of the day, s/he is still only one person, requiring one seat! That's the number I'm trying to get to.

    Does that make sense?

    Monday, June 9, 2014 4:30 AM
  • Add each recipient to a collection or list. use the email address as the key. Check for existing keys that match a new key when you try to add it. If it exists in the collection don't add it. At the end of iterating the recipients you'd end up with a collection of unique recipients.

    Ken Slovak MVP - Outlook

    • Marked as answer by Mike Bannen Tuesday, June 10, 2014 5:20 AM
    Monday, June 9, 2014 1:43 PM
    Moderator
  • Makes perfect sense. 

    After I have the collection (of email addresses),

    - is there a method for checking the meeting response status of each person, based on their email address?

    - any scenarios you know of where I need to code for NOT being able to get the email address?

    Thanks again.

    Tuesday, June 10, 2014 5:23 AM
  • For that you'd need to go backwards and match each address to a recipient. Then you can check the status for each recipient using Recipient.MeetingResponseStatus.

    You could also do that sort of processing as you extracted each recipient and retrieved their email address. You could use an array or something to store recipient name, address and response status, for example.


    Ken Slovak MVP - Outlook

    Tuesday, June 10, 2014 1:51 PM
    Moderator
  • For your second question, there are cases of nested DL's where at some point you can't get member addresses. So don't use nested DL's if possible.

    Also, if Exchange is being used Recipient.Address will return an Exchange DN and not an SMTP email address. In those cases you can use Recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress to retrieve the SMTP address.


    Ken Slovak MVP - Outlook

    • Marked as answer by Mike Bannen Monday, June 16, 2014 12:28 AM
    Tuesday, June 10, 2014 1:55 PM
    Moderator
  • Thanks Ken. I can't prevent Nested Distribution Lists (other people can create them in our org).

    Thanks a lot for tip on PrimarySmtpAddress

    Sunday, June 15, 2014 5:34 PM