...retrieve the folder list from Outlook?

Author: Mike Shkolnik
Homepage: http://www.scalabium.com

Category: Objects/ActiveX

uses
  
ComObj;

procedure RetrieveOutlookFolders(tvFolders: TTreeView);

  procedure LoadFolder(ParentNode: TTreeNode; Folder: OleVariant);
  var
    
i: Integer;
    Node: TTreeNode;
  begin
    for 
i := 1 to Folder.Count do
    begin
      
Node := tvFolders.Items.AddChild(ParentNode, Folder.Item[i].Name);

      LoadFolder(Node, Folder.Item[i].Folders);
    end;
  end;
var
  
outlook, NameSpace: OLEVariant;
begin
  
outlook   := CreateOleObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');

  LoadFolder(nil, NameSpace.Folders);

  outlook := Unassigned;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  
RetrieveOutlookFolders(TreeView1);
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base