General information
Category:
Object Oriented Programming
Dejan,
Here is a little snippet of code to get the Folder structure from outlook.
********************************************************************************
*--Program...........: OutLookFolders
*--Description.......: This Program Will Cycle Through Outlook and Produce a Cursor of the Available
*.....................: Folders and there Heirarchical Position.
*--Parameters........:
*--Author............: MATT LANDON
*--DevNotes1.........:
*--DevNotes2.........:
*--History...........:
*---6-28-2001-MPL-1.0.: Creation
********************************************************************************
CLOS ALL
CLEAR ALL
RELEASE ALL
*--6-28-2001-MPL: Create Outlook
loOutlook = CREATEOBJECT('Outlook.Application')
loNameSpace = loOutlook.GetNameSpace('MAPI')
CREATE CURSOR Outlookfolders( folderid c(10), folderlevel N(3),foldername c(50),parentfolder c(10))
*--6-28-2001-MPL: Start with the NameSpace and Get all SubFolders inside it.
GetSubFolders(loNameSpace,1,'Top Level')
FUNCTION GetSubFolders(toCurrentFolder,tnLevel,tcParentID)
PRIVATE toCurrentFolder,tnLevel,tcParentID,i,lctabvar
lctabvar = space(4*tnLevel)
FOR i = 1 TO toCurrentFolder.folders().COUNT
lcNextID = GetNextId('OutlookFolders')
INSERT INTO Outlookfolders VALUES (lcNextID,tnLevel,toCurrentFolder.folders(i).NAME,tcParentID)
?lctabvar + toCurrentFolder.folders(i).name
*--6-28-2001-MPL: Call the function recursively to get the subfolders for the current folder..
GetSubFolders(toCurrentFolder.folders(i),tnLevel+1,lcNextID)
ENDFOR
RETURN
ENDFUNC GetSubFolders
FUNCTION GetNextId(tcAlias)
SELECT MAX(VAL(folderid)) AS RecId FROM (tcAlias) INTO CURSOR Tada
PRIVATE lcNextID
lcNextID = PADL(ALLTRIM(STR(Tada.RecId + 1)),10,'0')
USE IN Tada
RETURN lcNextID
ENDFUNC GetNextId
********************************************************************************
After you have the appropriate folder try the following.
loContacts = loNameSpace.Folders('Folder1name').folders('folder2name')
for I = 1 to loContacts.items.count
?loContacts.items.item[i].FIRSTNAME + ' ' +;
loContacts.items.item[i].LASTNAME
ENDFOR
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only