Page 1
Page 2
Page 3
Now change the combo-box name to 'cmbFolderTypes'
and the style to vbComboDropdownList; change the text-box name to txtCnt
and the Locked property to True. Selecting the label above the combo-box
change the caption to 'Select a folder type', then change the other label
caption to '# Items'. Select the form and change the ScaleMode Property
to 'Pixel'. Your form should look something like the form below:

Double-click the form and add the following code to
the General Declarations area:
Option Explicit
Dim appPO As PocketOutlook.Application
Const constFolderCalendar = 9
Const constFolderContacts = 10
Const constFolderTasks = 13
Const constFolderCities = 101
Const constFolderInfrared = 102
Add the following code to the Form Load event,
making sure that the lines do not wrap as they do here:
Private Sub Form_Load()
'load combobox with values
cmbFolderTypes.AddItem "Show Outlook Calendar"
cmbFolderTypes.ItemData(cmbFolderTypes.NewIndex) = constFolderCalendar
cmbFolderTypes.AddItem "Show Outlook Contacts"
cmbFolderTypes.ItemData(cmbFolderTypes.NewIndex) = constFolderContacts
cmbFolderTypes.AddItem "Show Outlook Tasks"
cmbFolderTypes.ItemData(cmbFolderTypes.NewIndex) = constFolderTasks
cmbFolderTypes.AddItem "Show Outlook Cities"
cmbFolderTypes.ItemData(cmbFolderTypes.NewIndex) = constFolderCities
'cmbFolderTypes.AddItem "Show Outlook Contacts",constFolderInfrared
End Sub
Add the following code to the cmbFolderTypes
combo-box click event:
Private Sub cmbFolderTypes_Click()
PopulateCtrLWith List1, cmbFolderTypes.ItemData(cmbFolderTypes.ListIndex)
End Sub
and lastly add the eVB code to interact with the Pocket Outlook OM
as a form sub:
Private Sub PopulateCtrLWith(ctrlList
As ListBox, paramFolderType As Byte)
Dim Success
Dim objFolder
Dim colCollection
Dim objItem
Dim arb1 As Integer
ctrlList.Clear
'bind to the Pocket Outlook application
Set appPO = CreateObject("PocketOutlook.Application")
Success = appPO.Logon
'create obj reference to the appropriate folder
Set objFolder = appPO.GetDefaultFolder(paramFolderType)
Set colCollection = objFolder.Items
For arb1 = 1 To colCollection.Count
Set objItem = colCollection(arb1)
'Properties need to be differentiated
Select Case paramFolderType
Case constFolderTasks:
ctrlList.AddItem objItem.Subject
Case constFolderCalendar:
ctrlList.AddItem objItem.Subject
Case constFolderContacts:
ctrlList.AddItem objItem.LastName
Case constFolderCities:
ctrlList.AddItem objItem.Name
End Select
'disp item count
txtCnt.Text = CStr(colCollection.Count)
Set objItem = Nothing
Next
Set colCollection = Nothing
Set objFolder = Nothing
appPO.Logoff
Set appPO = Nothing
End Sub
Walking through the code
We will use the same subroutine code to access the
folders and retrieve the item collections, although when we access the different
items types we will selectively differentiate the properties we wish to
display.
Let's walk through the PopulateCtrLWith(ctrlList
As ListBox, paramFolderType As Byte) subroutine. The combo-box
click event calls this routine, passing a reference to the Listbox we
want to populate as well as the FolderType we want to enumerate (Calendar,
Contacts, Tasks or City).
The first thing we do is bind to the Pocket Outlook
application:
Set appPO = CreateObject("PocketOutlook.Application")
Success = appPO.Logon
and Logon to the application. I'm not sure why we
have the necessity of logging on since there is no namespace object -
I presume it is for backward compatibility.
Next we create a reference to the FolderType using
the paramFolderType parameter.
Set objFolder = appPO.GetDefaultFolder(paramFolderType)
Once we have a Folder we can iterate through the item
collection.
Set colCollection = objFolder.Items
For arb1 = 1 To colCollection.Count
Set objItem = colCollection(arb1)
'Properties need to be differentiate
'before we display the
'Select Case stmt...
'.....
Set objItem = Nothing
Next
As we interate through the items we need to display
different property information depending upon the target folder type (paramFolderType).
So if the FolderType is Tasks then we might want to show the Subject property,
if it is Contacts we may show the LastName property, and so on.
'Properties need to be differentiated
Select Case paramFolderType
Case constFolderTasks:
ctrlList.AddItem objItem.Subject
Case constFolderCalendar:
ctrlList.AddItem objItem.Subject
Case constFolderContacts:
ctrlList.AddItem objItem.LastName
Case constFolderCities:
ctrlList.AddItem objItem.Name
End Select
Previous Page
Next Page