1

I'm trying to get contact details in my outlook add-in using SelectNamesDialog. If the user selects individual contact items in the dialog, I'm able to get the details of each contact item using SelectNamesDialog. Recipients property. My problem is, if user selects a Contact Group instead of individual contacts, then I'm able to get its members. I'm able to differentiate if it's a single user or a contact group using this:

Outlook.SelectNamesDialog NamesDialog = Globals.ThisAddIn.Application.Session.GetSelectNamesDialog();
NamesDialog.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo;
NamesDialog.ForceResolution = true;

NamesDialog.Display();
foreach (Outlook.Recipient recipient in NamesDialog.Recipients)
{
    if (recipient.DisplayType == Outlook.OlDisplayType.olUser)
    {

    }
    else if (recipient.DisplayType == Outlook.OlDisplayType.olPrivateDistList)
    {
    }
}

But I'm unable to get the details of contacts if it's a contact group (DistList).

Can you please give me some hints how I can get the members if the NamesDialog. Recipient is a contact group instead of single user.

Thanks a lot.

user123
  • 1,060
  • 3
  • 13
  • 29

1 Answers1

0
            Outlook.ExchangeDistributionList exchDL =  addrEntry.GetExchangeDistributionList();
            Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers();
            if (addrEntries != null)
                foreach (Outlook.AddressEntry exchDLMember in addrEntries)
                {
                    Debug.WriteLine(exchDLMember.Name);
                }
Nissim
  • 6,395
  • 5
  • 49
  • 74
  • hi, thanks for response. I try this: Outlook.AddressEntry addEntry = recipient.AddressEntry; Outlook.ExchangeDistributionList exchDL = addEntry.GetExchangeDistributionList(); but exchDL remains null – Zeeshan Akram Jun 21 '15 at 06:46