Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Retrieve a folder list from MS Outlook Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
04-Jun-03
Category
OLE
Language
Delphi 2.x
Views
135
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

Do you want to use the MS Outlook from Delphi application?

Answer:

The procedure below allow to load a tree of available folders into TTreeView: 

1   procedure RetrieveOutlookFolders(tvFolders: TTreeView);
2   
3     procedure LoadFolder(ParentNode: TTreeNode; Folder: OleVariant);
4     var
5       i: Integer;
6       node: TTreeNode;
7     begin
8       for i := 1 to Folder.Count do
9       begin
10        node := tvFolders.Items.AddChild(ParentNode,
11          Folder.Item[i].Name;
12  
13          LoadFolder(node, Folder.Item[i].Folders);
14      end;
15    end;
16  
17  var
18    outlook, NameSpace: OLEVariant;
19  begin
20    outlook := CreateOleObject('Outlook.Application');
21    NameSpace := outlook.GetNameSpace('MAPI');
22  
23    LoadFolder(nil, NameSpace.Folders);
24  
25    outlook := UnAssigned;
26  end;


A few comments: 

the data in Outlook have the next structure: outlook application defines a MAPI's 
namespace which have a collection of folders. Each folder contains an items or 
sub-folders 
this code load a full tree in TreeView. Of course, if you have a lot of pst-files 
with messages (active, archive, backup etc) and each of this pst-file have a large 
structure of folders, this code will work slowly. So as suggestion: you can rewrite 
a code and load the one level only. In this case code will work quickly and a list 
of sub-folders you'll receive in OnExpanding event of your TreeView 
each folder of Outlook have an unique idenifier. You can save it somewhere (for 
example, in Data property of TTreeNode). Remember that this ID is long string value 
which you can receive as EntryID in loop of LoadFolder procedure: 

Folder.Item[i].EntryID

PS: if this topic is interested for you, I'll continue this serie of tips and shall show how to load the messages/contacts/tasks/etc from some folder or create a new item. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC