Article ID: 265771
Article Last Modified on 1/6/2006
APPLIES TO
- Microsoft eMbedded Visual Basic 3.0
- Microsoft Windows CE Toolkit for Visual Basic 6.0
This article was previously published under Q265771
SUMMARY
This article introduces the Pocket Outlook Object Model (POOM) SDK to developers who use Microsoft Windows CE Toolkit for Visual Basic 6.0 (VBCE6) or eMbedded Visual Basic 3.0 (eVB). The following topics are covered:
- What is the Pocket Outlook Object Model (POOM) SDK?
- Where to obtain the POOM SDK.
- How to install and register the POOM SDK on a device.
- Emulation.
- An overview of the POOM.
- How you can begin to program with the POOM SDK, as follows:
- How to log on and log off.
- How to create a new contact.
- How to view information about a contact.
- How to obtain a list of contacts.
- How to create an appointment.
- How to obtain appointment information.
- How to create a task.
- How to obtain task information.
- How to add a city.
- How to obtain city and time zone information.
- How to specify a home and visiting city.
- How to send items through Infrared transfer.
- How to receive items through Infrared transfer.
MORE INFORMATION
- What is the Pocket Outlook Object Model (POOM) SDK?
The Pocket Outlook Object Model SDK is the means by which the object model for Pocket Outlook is exposed to programmers who use the Windows CE Toolkits for Visual Basic 6.0 and Microsoft Visual C++ 6.0 (VCCE6), as well as the eMbedded Visual Tools 3.0. This allows for programmatic manipulation of Contact, Calendar, and Task data, as well as the capability to view City and TimeZone information. - Where to obtain the POOM SDK.
The POOM SDK can be downloaded from the following Microsoft Web site: How to install and register the POOM SDK on a device.
Note The pimstore.dll file is already present in ROM on Pocket PC devices, so the following steps are not necessary for Pocket PC.
After you download the POOM SDK, run the pimstore.exe file to extract its contents. To use the POOM, you need to install and register pimstore.dll file on your Windows CE Companion device. The DLL for each CPU is copied to your PC when you download and run the self-extracting .exe file. The DLLs are distinguished by name; for example, pimstore_sh3.dll supports the SH3 processor. To use POOM, drag the pimstore_*.dll for your CPU to the \Windows directory of your companion device. Rename the DLL to "pimstore.dll" without the underscore and CPU designation.
Register the pimstore.dll on the device. You can do this in several different ways, which include running regsvr.exe on the device as follows:\windows\regsvr.exe \windows\pimstore.dll
Another alternative is to compile the sample code that is listed in the POOM SDK ReadMe.txt file.
- Emulation.
The POOM SDK is supported with the Pocket PC emulation environment.
- An overview of the POOM.
The Pocket Outlook Object Model is modeled after the Microsoft Outlook 97 and Microsoft Outlook 98 Object Models on the desktop. In order to provide a smaller DLL that is better suited for Windows CE devices, POOM is a smaller subset of the desktop Outlook Object Model.
The Pocket Outlook Object Model meets the following goals:- Backward compatibility. The component runs on the following platforms:
- Handheld PC 2.0
- Handheld PC Pro 3.0
- Handheld PC 2000
- Palm-size PC 1.2
- Pocket PC
- Future extensibility. The interfaces are designed to be extensible in the future. For example, there is a Folder object, which is little more than a wrapper around a database in this version.
- Outlook compatibility. Although it is based on the desktop edition of the Outlook Object Model, there are some differences that exist to achieve simplicity on the device. For example, a NameSpace object is not provided, which Outlook uses to log on to a MAPI session, and which would be an extra layer on Windows CE devices. It is more accurate to say that the Pocket Outlook Object Model is based on the desktop Outlook Object Model rather than to say it is a subset of the model.
- Automation object. The automation object has a dual interface that allows Microsoft Visual Basic and scripting programmers to use the Object Model. Although the method and property names are more complicated in Microsoft C or Visual C++ than they are in Visual Basic, this is an important trade-off for customers.
- Simplicity. The interfaces are meant to be quite simple and, as such, represent a small subset of the desktop Outlook Object Model functionality.
The main interface to the Pocket Outlook Object Model is the Pocket Outlook Application object. All other objects are derived from this. After you log on to the Application object, you can access various Folder objects.
A Folder object contains a collection of Items. This folder implementation is a subset of the Folder object of Outlook. The Folder object is a wrapper for the Contacts, Clock, Calendar, and Tasks databases. There is only one folder for each type of item. The Folder object itself cannot be created or otherwise manipulated. The Folder object is provided mainly for compatibility with Outlook. An Infrared Folder is also provided, which you can use to send items over an Infrared port.
From the Folder object, you have the Items collection, which is a collection of Contacts, Tasks, Appointments, or Cities. From an Items collection, you can retrieve or create individual items. The Items collection also allows you to do basic filtering over a collection of objects.
With an individual Item, you can set and retrieve individual properties. You can create, modify, or delete an item in the store. Note that Cities are read-only items and cannot be created or modified.
Task and Appointment items support the RecurrencePattern object that lets you set up a recurrence for a task or an appointment. Appointments also support the Recipients collection that allows you to specify recipients for a meeting. If an appointment has a recipients collection, it is a meeting request.
The following table represents the basic Pocket Outlook Object Model:Application Object Folder Object Calendar Cities Contacts Infrared Tasks - Backward compatibility. The component runs on the following platforms:
- How You Can Begin to Program with the POOM SDK.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Before you start to program with the POOM, set a reference to the DLL to use IntelliSense Help. To do this, on the Project menu, select References, and then browse until you find the pimstore_i486.dll file that ships with the POOM.How to log on and log off
The Logon and Logoff methods should be the first and last methods called, respectively, on a Pocket Outlook Application Object. Logon logs the user onto a Pocket Outlook session and Logoff logs the user out.
These methods are called as follows:Option Explicit Dim pOLA As PocketOutlook.Application Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") 'Since you are going to be displaying items, you pass in the 'form’s HWND to Logon so that dialog boxes will be parented to 'this window. Otherwise, the user could display 'multiple items at a time. pOLA.Logon (Form1.hWnd) 'logs on to a session End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff 'logs off of a session End Sub
- How to create a new contact
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pContact As PocketOutlook.ContactItem Const olCreateContact = 2 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) AddNewContact "Maxwell", "Smart" End Sub Function AddNewContact(sFirstName As String, sLastName As String) As Long Set pContact = pOLA.CreateItem(olCreateContact) pContact.FirstName = sFirstName pContact.LastName = sLastName pContact.Save Set pContact = Nothing End Function Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to view information about a contact
Note This sample assumes that a specific contact exists.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pContact As PocketOutlook.ContactItem Const olFolderContacts = 10 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() DisplayContact "Smart, Maxwell" End Sub Sub DisplayContact(inpContactName As String) Set pContact = pOLA.GetDefaultFolder(olFolderContacts).Items.Find( _ "[FileAs] = """ & inpContactName & """") Set pContact = pOLA.GetItemFromOid(pContact.oid) pContact.Display Set pContact = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to obtain a list of contacts
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a ListBox control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pContact As PocketOutlook.ContactItem Dim pItems As PocketOutlook.Items Const olFolderContacts = 10 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) GetContacts List1 End Sub Private Sub GetContacts(lstCtrl As ListBox) Dim i As Integer lstCtrl.Clear 'Add all the Contacts to a ListBox. Start by getting the 'Contacts folder, and then get its Item Collection. Set pItems = pOLA.GetDefaultFolder(olFolderContacts).Items For i = 1 To pItems.Count Set pContact = pItems.Item(i) lstCtrl.AddItem i & ": " & pContact.FileAs Next i Set pItems = Nothing Set pContact = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to create an appointment
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pApptItem As PocketOutlook.AppointmentItem Const olCreateAppointment = 1 Private Sub Command1_Click() NewAppt "Meet with Chief", "Cone of Silence Room", _ "Discuss shoe phone repair bills", _ CDate("12/15/00 08:30:00 AM"), _ CDate("12/15/00 10:30:00 AM") End Sub Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub NewAppt(sSubject As String, sLoc As String, _ sBody As String, dStart As Date, dEnd As Date) Set pApptItem = pOLA.CreateItem(olCreateAppointment) pApptItem.Subject = sSubject pApptItem.Location = sLoc pApptItem.Body = sBody pApptItem.Start = dStart pApptItem.End = dEnd pApptItem.Save Set pApptItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to obtain appointment information
Note This sample assumes that an appointment exists for today.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton and a ListBox control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pApptItem As PocketOutlook.AppointmentItem Dim pItems As PocketOutlook.Items Const olFolderCalendar = 9 Private Sub Command1_Click() ViewTodaysAppointments Date, List1 End Sub Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Sub ViewTodaysAppointments(inpDate As Date, lstCtrl As ListBox) Dim iItem As Integer lstCtrl.Clear Set pItems = pOLA.GetDefaultFolder(olFolderCalendar).Items 'Use the Restrict method to find only those items with a start 'date of today. pTodaysItems will be a new Item Collection that 'contains only those items that pass the restriction of 'occurring today. Set pItems = pItems.Restrict("[Start] = """ & inpDate & """") For iItem = 1 To pItems.Count Set pApptItem = pItems.Item(iItem) lstCtrl.AddItem pApptItem.Subject & " at " & _ FormatDateTime(pApptItem.Start, vbShortTime) Next Set pItems = Nothing Set pApptItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to create a task
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pTaskItem As PocketOutlook.TaskItem Const olCreateTasks = 3 Const olDialog = 1 Const olSound = 8 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() NewTask "Pick up shoe phone at repair shop", "Watch out for KAOS", _ Now() + 2, Now(), "Alarm3", True End Sub Sub NewTask(sSubject As String, sBody As String, _ dDue As Date, dStart As Date, _ sSoundFile As String, bReminderSet As Boolean) Set pTaskItem = pOLA.CreateItem(olCreateTasks) pTaskItem.Subject = sSubject pTaskItem.Body = sBody pTaskItem.DueDate = dDue pTaskItem.StartDate = dStart pTaskItem.ReminderSet = bReminderSet If bReminderSet Then pTaskItem.ReminderOptions = olSound Or olDialog pTaskItem.ReminderSoundFile = sSoundFile pTaskItem.ReminderTime = dDue - 1 End If pTaskItem.Save Set pTaskItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.logoff Set pOLA = Nothing End Sub
- How to obtain task information
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add two CommandButton controls and one ListBox control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pTaskItem As PocketOutlook.TaskItem Dim pItems As PocketOutlook.Items Const olFolderTasks = 13 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) Command1.Caption = "View Today's Tasks" Command2.Caption = "View All Tasks" End Sub Private Sub Command1_Click() ViewTodaysTasks Date + 1, List1 End Sub Private Sub Command2_Click() ViewAllTasks List1 End Sub Sub ViewTodaysTasks(inpDate As Date, lstCtrl As ListBox) Dim iItem As Integer lstCtrl.Clear Set pItems = pOLA.GetDefaultFolder(olFolderTasks).Items 'Use the Restrict method to find only those items with a due 'date of today. Set pItems = pItems.Restrict("[Duedate] = """ & inpDate & """") For iItem = 1 To pItems.Count Set pTaskItem = pItems.Item(iItem) lstCtrl.AddItem pTaskItem.Subject Next Set pItems = Nothing Set pTaskItem = Nothing End Sub Sub ViewAllTasks(lstCtrl As ListBox) Dim iItem As Integer lstCtrl.Clear Set pItems = pOLA.GetDefaultFolder(olFolderTasks).Items For iItem = 1 To pItems.Count Set pTaskItem = pItems.Item(iItem) lstCtrl.AddItem pTaskItem.Subject & " on " & _ FormatDateTime(pTaskItem.DueDate, vbShortDate) Next Set pItems = Nothing Set pTaskItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
- How to add a city
Cities exist in the World Clock Control Panel applet and can be either user-defined or in ROM. In ROM, cities cannot be modified.
Note On Pocket PC-based devices, Cities information is found on the Settings menu option in the Clock applet.
When you set either the Longitude or Latitude properties of the City object, use the following standards:- West is negative, East is positive. For example, 104.98 degrees W is -10498.
- South is negative, North is positive. For example, 39.77 degrees N is 3977.
Note Before you run the following code, close the World Clock Control Panel applet (Clock applet on Pocket PC-based devices). Otherwise, an error results.
- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pCityItem As PocketOutlook.CityItem Dim pItems As PocketOutlook.Items Const olFolderCities = 101 Const olCreateCity = 102 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() AddNewCity "Steilacoom, WA", "USA" End Sub Private Sub AddNewCity(sCityName As String, _ sCountryName As String) 'Check to see if city exists first because 'we won't get an error if it's created twice. If CityExists(sCityName) = True Then MsgBox "City already exists" Exit Sub End If Set pCityItem = pOLA.CreateItem(olCreateCity) pCityItem.Name = sCityName pCityItem.Country = sCountryName pCityItem.Save Set pCityItem = Nothing End Sub Private Function CityExists(sCityName As String) As Boolean Set pItems = pOLA.GetDefaultFolder(olFolderCities).Items Set pCityItem = pItems.Find("[NAME] = """ & sCityName & """") If pCityItem Is Nothing Then CityExists = False Else CityExists = True End If Set pCityItem = Nothing End Function Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
- How to obtain city and time zone information
Note Before you run the following code, close the World Clock Control Panel applet (Clock applet on Pocket PC-based devices). Otherwise, an error results.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Const olFolderCities = 101 Dim pOLA As PocketOutlook.Application Dim pCity As PocketOutlook.CityItem Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() FindCityTimeZone "Sioux Falls, SD" End Sub Private Sub FindCityTimeZone(inpCity As String) Dim sTimeZone As String Set pCity = pOLA.GetDefaultFolder(olFolderCities).Items.Find( _ "[NAME] = """ & inpCity & """") sTimeZone = pOLA.GetTimeZoneFromIndex( _ pCity.TimezoneIndex).StandardName MsgBox pCity.Name & " is in the '" & sTimeZone & "' time zone." Set pCity = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
- How to specify a home and visiting city
Note Before you run the following code, close the World Clock Control Panel applet (Clock applet on Pocket PC-based devices). Otherwise, an error results.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add two CommandButton controls to Form1.
Paste the following code into Form1:
Option Explicit Const olFolderCities = 101 Const olHomeCity = 0 Const olVisitingCity = 1 Dim pOLA As PocketOutlook.Application Dim pCity As PocketOutlook.CityItem Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) Command1.Caption = "Visiting" Command2.Caption = "Home" End Sub Private Sub Command1_Click() CitySetVisit "Vancouver, BC" End Sub Private Sub Command2_Click() CitySetHome "Seattle, WA" End Sub Private Sub CitySetVisit(inpCity As String) Set pCity = pOLA.GetDefaultFolder(olFolderCities).Items.Find( _ "[NAME] = """ & inpCity & """") pOLA.VisitingCity = pCity pOLA.CurrentCityIndex = olVisitingCity MsgBox "Visiting city is now: " & pOLA.VisitingCity.Name Set pCity = Nothing End Sub Private Sub CitySetHome(inpCity As String) Set pCity = pOLA.GetDefaultFolder(olFolderCities).Items.Find( _ "[NAME] = """ & inpCity & """") pOLA.HomeCity = pCity pOLA.CurrentCityIndex = olHomeCity MsgBox "Home city is now: " & pOLA.HomeCity.Name Set pCity = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
- How to send items through Infrared transfer
This sample sends a newly created TaskItem through Infrared transfer.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pFolder As PocketOutlook.Folder Dim pTaskItem As PocketOutlook.TaskItem Const olTaskItem = 3 Const olFolderInfrared = 102 Const olCreateTasks = 3 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() 'Set up a task Set pTaskItem = pOLA.CreateItem(olCreateTasks) pTaskItem.Subject = "Pick up shoe phone at repair shop" pTaskItem.StartDate = Now 'today pTaskItem.DueDate = Now + 1 'tomorrow pTaskItem.Save 'Ship it over Set pFolder = pOLA.GetDefaultFolder(olFolderInfrared) pFolder.AddItemToInfraredFolder olTaskItem, pTaskItem pFolder.SendToInfrared Set pFolder = Nothing Set pTaskItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
- How to receive items through Infrared transfer
This sample receives a TaskItem sent through Infrared transfer.- Create a new Windows CE Project in eMbedded Visual Basic. Form1 is created by default.
- Add a CommandButton control to Form1.
Paste the following code into Form1:
Option Explicit Dim pOLA As PocketOutlook.Application Dim pFolder As PocketOutlook.Folder Dim pItems As PocketOutlook.Items Dim pTaskItem As PocketOutlook.TaskItem Const olFolderTasks = 13 Private Sub Form_Load() Set pOLA = CreateObject("PocketOutlook.Application") pOLA.Logon (Form1.hWnd) End Sub Private Sub Command1_Click() 'Get the task from Infrared transfer Set pFolder = pOLA.GetDefaultFolder(olFolderTasks) Set pItems = pFolder.ReceiveFromInfrared 'Verify we got it Set pTaskItem = pItems.Item(1) MsgBox pTaskItem.Subject, vbCritical, "Task Received!" Set pFolder = Nothing Set pItems = Nothing Set pTaskItem = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) pOLA.Logoff Set pOLA = Nothing End Sub
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.
REFERENCES
For more information, see the "Pocket Outlook Object Model.doc" topic that is included with the POOM SDK download at the following Microsoft Web site:
For additional information, see "Using the Pocket Outlook Object Model SDK" at the following Microsoft Web site:
Additional query words: evc
Keywords: kbhowto kboswincesearch kboutlook kbvbp600 kbgrpdsvb kbvbm300 KB265771