WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Recurse Outlook folders


;created by jalverson Wednesday, June 11, 2003 08:02 PM  






;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_olemsg_folders_property_folder.asp
;

;   give this a whirl, try creating a contact sub-folder and then run it.
;   if you want only contacts then uncomment line 12 and comment line 13...
#definefunction GetSubFolders(folder)
   subFolders = folder.Folders
   hEnum = ObjectCollectionOpen(subFolders)
   while @true
     objFolder = ObjectCollectionNext(hEnum)
     if objFolder == 0 then break
;      if objFolder.DefaultItemType == 2 then clipappend(strcat(strfix(objFolder.Name, " ", 30), @tab, objFolder.DefaultItemType, @crlf))
      clipappend(strcat(strfix(objFolder.Name, " ", 30), @tab, objFolder.DefaultItemType, @crlf))
      GetSubFolders(objFolder)
     objectclose(objFolder)
   endwhile
   ObjectCollectionClose(hEnum)
   return
#endfunction

objOutlook = objectopen("Outlook.Application")
mapi = objOutlook.GetNameSpace("MAPI")

objSession = mapi.session ;objectopen("MAPI.Session")
objFolders = mapi.folders ;objectopen("MAPI.Folders")

clipput("")

hEnum = ObjectCollectionOpen(objFolders)
while @true
  objFolder = ObjectCollectionNext(hEnum)
  if objFolder == 0 then break
   clipappend(strcat(objFolder.Name, @crlf))
   GetSubFolders(objFolder)
  objectclose(objFolder)
endwhile
ObjectCollectionClose(hEnum)

objectclose(objSession)
objectclose(objFolders)
objectclose(mapi)
objectclose(objOutlook)

message("Folders", clipget())

exit

Article ID:   W16094
File Created: 2004:03:30:15:42:50
Last Updated: 2004:03:30:15:42:50