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.

Identify Outlook Folder Type or Contents


Question:

Is it possible to easily identify the type or contents of an Outlook folder from Outlooks folder list? Possibly using the Class Property of an item. For example if it was required to identify a folder which contained Outlook contacts this has items with olContact = 40.

It is possible to list the Outlook folder list using the following code but how can any folder containing contacts be identified?

objOutLook = ObjectOpen ("Outlook.Application")
objNameSpace = objOutLook.GetNamespace("MAPI")
;Get all folders
objNSFolders = objNameSpace.Folders('Personal Folders')
objFolders = objNSFolders.Folders
count = objFolders.Count
list = "" 
for xx = 1 to count
objItem = objFolders.Item(xx)
name = objItem.name
list = strCat(list,@tab,name)
ObjectClose(objItem)
next
folderchosen = AskItemList("folderlist",strtrim(list),@tab,@unsorted,@single)
Message("folder chosen",folderchosen)

Answer:

Maybe check out the DefaultItemType Property...
objOutLook = ObjectOpen ("Outlook.Application")
objNameSpace = objOutLook.GetNamespace("MAPI")
;Get all folders
objNSFolders = objNameSpace.Folders('Personal Folders')
objFolders = objNSFolders.Folders
count = objFolders.Count
 
for xx = 1 to count
objItem = objFolders.Item(xx)
type = objItem.DefaultItemType 
Switch type
	case 0 ;olMailItem 
	  typename = "Mail Item"
	break

	case 1 ;olAppointmentItem
	  typename = "Appointment Item"
	break

	case 2 ;olContactItem 
	  typename = "Contact Item"
  	break

	case 3 ;olTaskItem 
	  typename = "Task Item"
	break

	case 4 ;olJournalItem 
	  typename = "Journal Item"
	break

	case 5 ;olNoteItem
 	  typename = "Note Item"
	break

	case 6 ;olPostItem
 	  typename = "Post Item"
	break

	case 7 ;olDistributionListItem
	  	  typename = "Distribution List Item"
	break

	case type
		 typename = "UNKNOWN"
	break


EndSwitch
name = objItem.name  
Message(name,typename)

ObjectClose(objItem)
ObjectClose(objFolders)
ObjectClose(objNSFolders)
ObjectClose(objNameSpace)
ObjectClose(objOutLook)
next




Article ID:   W16092
File Created: 2004:03:30:15:42:48
Last Updated: 2004:03:30:15:42:48