Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetOLFolder()

Status
Not open for further replies.

DChalom

Programmer
Jun 8, 2002
59
US
Can someone tell me how I would go about creating a function that would allow a user to select a folder in OutLook to scan through the emails in it?

Dorian C. Chalom
 
DChalom

Folders in Outlook are not like folder in your system, you cannot get at them like you would with windows explorer. I would suggest you create an interface that would :
[ol][li]Scan through the different folders in Outlook and pick up the names of them (You were shown how to do this in a recent post)[/li]
[li]Create a grid with a cursor that contains the names of all the folders names you picked up in the above function.[/li]
[li]Let the user select the folder he wants to scan through, and take whatever action is required.[/li][/ol]

Or you may want to start with a sample interface. Take a look faq184-3808.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Dorian.

Here is some sample code (untested!!!) to give you an idea of how to populate a cursor that you can later use to display the folder names in a list box:

Code:
*** You can use these to decide if you want
*** to include the folder in the cursor
#DEFINE olMailItem	0	
#DEFINE olAppointmentItem	1	
#DEFINE olContactItem	2	
#DEFINE olTaskItem	3	
#DEFINE olJournalItem	4	
#DEFINE olNoteItem	5	
#DEFINE olPostItem	6	
#DEFINE olDistributionListItem	7	

LOCALE loRootFolder
PRIVATE poOutlook, poNameSpace
CREATE CURSOR FolderNames ( FldrName C( 50 ), DefaultItemType I )
poOutLook = CREATEOBJECT( 'Outlook.Application' )
IF VARTYPE( poOutLook ) = 'O'
  poNameSpace = poOutlook.GetNamespace( 'MAPI' )
  loRootFolder = poNameSpace.Folders(1)
  GetSubFolders( loRootFolder )
ENDIF

FUNCTION GetSubFolders( toFolder )
LOCAL loFolders, loFolder

*** Check for the defaultItemType if you want
*** to include only folders that contain mail items
IF toFolder.DefaultItemType = 0  && olMailItem
  INSERT INTO FolderNames ( FldrName, DefaultItemType ) VALUES ( loRootFolder.Name, loRootFolder.DefaultItemType )
ENDIF

*** Now see if this folder has folders to process
IF toFolder.Class = 2	&&	olFolder	
  loFolders = toFolder.Folders
  FOR EACH loFolder IN loFolders
    GetSubFolders( loRootFolder )
  ENDFOR
ENDIF

Marcia G. Akins
 
There has to be a way to do this. I want to create a kind of GetFolder but to do it using the Outlook folder structure....

Dorian C. Chalom
 
DChalom

There has to be a way to do this.

If you find one, post it here.

If you take Marcia's sample code and create a cursor and build a treeview base on that cursor and simulate a treeview of the folders in Outlook.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top