Board index » delphi » loading details from outlook98 contacts folder

loading details from outlook98 contacts folder

Hi

i'm trying to load information from my outlook98 contacts folder into a
dropdown combo.

the following code works but occasionally crashes out with 'Interface
not supported' and 'index array out of bounds'
also i can never get the whole list of names.
I put in a sleep command which meant more info was retrieved but I still
cant get the whole list of names. But it does seem that the longer the
sleep
command the more info i can retrieve. Odd !

    cmboContactNames.Clear;
    for iii := 1 to ContactsFolder.Items.Count-1 do
    begin
      ltemp := (ContactsFolder.Items.Item(iii) as ContactItem).FullName;

      sleep(2500);
      cmboContactNames.Items.Add(ltemp);
      sleep(2500);
    end;
    cmboContactNames.Sorted := True;
    cmboContactNames.ItemIndex := 0;

its very bizarre and any help would be much appreciated

thanks

 

Re:loading details from outlook98 contacts folder


<<Lloyd:
But it does seem that the longer the sleep
command the more info i can retrieve. Odd !

Quote

Very odd. Let's deal with the 'interface not supported'
first - that must be coming from the as operation. So try
this:
var
  CI: ContactItem;
  Item: IDispatch;
..
  for i := 1 to Contacts.Items.Count do
  begin
    Item := Contacts.Items.Item(i);
    if Supports(Item, ContactItem, CI) then
      cmboContactNames.Items.Add(CI.FullName);
..

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads