MAPIFolder.Items collection returns either Outlook.ContactItem or
Outlook.DistListItem objects, but never Outlook.AddressEntry object.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> I'm attempting to access the entries in an Outlook user's contact list
> from within an Outlook plugin in C# (using Visual Studio 2003 and
[quoted text clipped - 5 lines]
> Outlook.ApplicationClass().GetNamespace("MAPI");
> Outlook.Items coll =
outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items;
> MessageBox.Show("Got collection. item count is " + coll.Count);
> MessageBox.Show("First item uncast is " + coll.GetFirst());
[quoted text clipped - 6 lines]
>
> Thanks!
Dmitry Streblechenko \(MVP\) - 25 Oct 2004 19:55 GMT
Clarification: MAPIFolder.Items collection returns either
Outlook.ContactItem or Outlook.DistListItem objects for the Contact
folders. For other folders it can be MailItem, TaskItem, etc.
As a rule of thumb, you should be checking the Class property (all Outlook
objects have that property) - for the contact items (ContactItem), it is 40.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> MAPIFolder.Items collection returns either Outlook.ContactItem or
> Outlook.DistListItem objects, but never Outlook.AddressEntry object.
[quoted text clipped - 13 lines]
> > Outlook.ApplicationClass().GetNamespace("MAPI");
> > Outlook.Items coll =
outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items;
> > MessageBox.Show("Got collection. item count is " + coll.Count);
> > MessageBox.Show("First item uncast is " + coll.GetFirst());
[quoted text clipped - 6 lines]
> >
> > Thanks!
Tim Shirley - 29 Oct 2004 15:56 GMT
Ah, stupid me.. That fixed it. Thank you very much!!
> Clarification: MAPIFolder.Items collection returns either
> Outlook.ContactItem or Outlook.DistListItem objects for the Contact
[quoted text clipped - 36 lines]
> > >
> > > Thanks!