Board index » delphi » Outlook 2000 Automation In D6

Outlook 2000 Automation In D6

  I've recently had a need to programmatically access my Outlook 2000
contacts from Delphi 6, thanks to a number of messages here I've got a
basic program working to read and update contacts in the default
contacts folder but I'm having some problems getting to the next step.

  In outlook I have three .pst files open (under Folder List the roots
are: 'Contacts Folders', 'Outlook Today - [Personal Folders]' and
'Personal Folders') and while my default folders (where my Inbox,
Outbox, Sent Items are located) does contain a default 'Contacts' list I
have several other contact lists in the .pst file but also I have a
number of large contact lists in the 'Contacts Folder' .pst file. What I
need to do is get a folder list and then iterate through each folder
getting the the names of each contact list so that I can choose which
one I want to perform an operation on. This is something I haven't been
able to find an example of but I see in the Outlook2000.pas file a
'Get_Folders' function but I'm stuck as far as what parameters I should
be passing and what type of result the function gives? Can anyone give
me some guidance here?

Thanks,

- Chris LeFebvre

 

Re:Outlook 2000 Automation In D6


On Thu, 05 Jun 2003 14:28:11 -0400, Chris LeFebvre

Quote
<LeFebv...@Comcast.Net> wrote:
>What I
>need to do is get a folder list and then iterate through each folder
>getting the the names of each contact list so that I can choose which
>one I want to perform an operation on.

The following procedure runs through the hierarchy of Outlook folders
and writes the folder paths to a TStrings object:

procedure ListFolders(Strings: TStrings);

  procedure AddFolders(const Path: string; FolderList: _Folders);
  var
    i: Integer;
    FolderName: string;
  begin
    for i := 1 to FolderList.Count do
    begin
      FolderName := Path + FolderList.Item(i).Name;
      Strings.Add(FolderName);
      AddFolders(FolderName + '\', FolderList.Item(i).Folders);
    end;
  end;

begin
  Strings.Clear;
  AddFolders('',
    CoOutlookApplication.Create.GetNamespace('MAPI').Folders);
end;

You can use that as a starting point. If you're only interested in
contact folders, check the folder's DefaultItemType property - if it
is olContactItem, the folder should contain contacts and distribution
lists.

---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)

Re:Outlook 2000 Automation In D6


        Yorai:
  That's great, I gave it a try and it works like a charm.

- Chris LeFebvre

Other Threads