how to find out if its a Contact or a Distribution List

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi
I need to export all Contacts from a specified folder.
It works all fine, but if i put a Distribution list into the folder,
my programm crashes. I tryed the following but it didnt work:

_ItemsPtr pItems = pFolder->get_Items();
_ContactItemPtr pContact;

//Count the Items
long lContactCount = pItems->Count;

//get first contact
pContact = pItems->GetFirst();

for(long i = 1; i <= lContactCount; i++){

if(i != 1){
pContact = pItems->GetNext();
}

if(pContact->get_Class() == olContact){
AnsiString sTemp;
sTemp = pContact->get_FullName();

//Display the item in a Message Box (only for testing)
Application->MessageBoxA(sTemp.c_str(),"Contact",MB_OK);
}
}


I'm working with C++ Builder from Borland.
Can anybody help me?
 
You can use a late bound Object equivalent and then check for .MessageClass.
For a contact item the left-most part of the message class would be
"IPM.Contact". You can also check that the .Class of the item is olContact.
You can also set the item to a ContactItem and handle the error if it's the
wrong item type.
 
Thank You! But i found the misstake. I made the check at the wrong
position. I have to do it BEFORE I reference the pContact to the Item.
Like this:
if(!pItems->get_Class() == olContact){
pContact = pItems->GetNext();
}
 
Back
Top