Search code examples
listoutlooklistboxoutlook-addincontactitem

How to display the ContactItems Firstname in a ListBox


I got a list of Outlook Contacts and want to display them in a ListBox. This is the code I use to add every Contact to the ListBox but

foreach (ContactItem contact in contactItemsList)
            {
                ListBox_contacts.Items.Add(contact);
            }

The problem I have is with the output of the ListBox. Rather than showing the FirstName of each Contact it shows only: System.__ComObject

I read some things with overriding the ToString()- method but wasn´t able to understand how I should do that.


Solution

  • How about just

    ListBox_contacts.Items.Add(contact.Firstname);