Tech Note 03l: Accessing Pocket Outlook Files

September 08, 2007

© NSB Corporation. All rights reserved.

IMPORTANT: Support for accessing the Pocket Outlook Object Model from ActiveX was officially dropped in Windows CE 4.0. However, it continued to to work until part way through Windows CE 5.0. The highest version of PimStore.dll that works appears to be 5.01.14847. As of this time, there is no workaround. Possibilities are to use the DECLARE statement to call the API functions directly or to create a DLL wrapper that can be called from NS Basic/CE.

 

Using the Pocket Outlook Object Model (POOM) from Microsoft, it's easy to read and write to the built in databases for

You need to download the complete documentation and files from Microsoft's website. In this Tech Note, we'll give you a summary of what you need to know to use POOM from NS Basic/CE. The documentation provided by Microsoft is written from the viewpoint of a Visual C++ programmer. You will find that doing the same functions from NS Basic/CE is much easier!

Installation

If your device doesn't already have the files in ROM, you will need to move the appropriate version of PIMStore_xxx.dll from the release files to your device and rename it to PIMstore.dll. After that, it will need to be registered.

On HPC and HPC Pro devices, tap [start]...[run], then enter the command

regsvrce.exe \windows\pimstore.dll

You should get a message back that it has been registered successfully.

Basic Principles

POOM is an object, much like the other objects NS Basic/CE uses. The major difference is that in addition to having properties and methods, it also has objects within it. The main object has 4 objects inside it. Each one is called a Folder Object. The Folder Objects are Tasks, Appointments, Contacts, and Cities. The getDefaultFolder method is used to get a Folder Object.

Each of the Folder Objects has properties and methods (like any object) and an object called Items within it. The Items object has a property called count, which says how many individual items there are, and an array of those items which is an collection object called Items.

These items are the actual data. Each of these items is an object. For example, each name in Contacts is an object, referenced in the Items array. The values for the item are stored as properties: for example, lastname, title and Birthday are all properties of a Contact Item Object.

To sum up, there are 4 levels of objects set up as a hierarchy:

1. POOM Object (IPOutlookApp)

2. Folder Objects: Tasks, Appointments, Contacts, Cities (IFolder)

3. Items Object: An array with each Item (IPOutlookItemCollection)

4. Item Object (ICity, IContact, ITask or IAppointment)

Hint: if you have an object and you wonder what kind it is, do typename(object). It will return its type, something like ICity or IFolder.)

 

1. POOM Object (IPOutlookApp)

You create the POOM object using the AddObject statement as follows:

addobject "pocketOutlook.application","pol"
pol.logon
set tasks=pol.getdefaultfolder(13)
'do your processing here
pol.logoff

 

 

Name

Type

Notes

Version

Property

The current version of POOM

CurrentCityIndex

Property

0 or 1, depending on whether the user is in the home or visiting city.

HomeCity.name

Property

The home city.

VisitingCity.name

Property

The visiting city.

OutlookCompatible

Property

TRUE if synched with Outlook, FALSE if synched with Schedule+.

GetDefaultFolder(n)

Method

returns the selected object. Values for N are:
9 Calendar
10 Contacts
13 Tasks
101 Cities

Logon

Method

logs user on to POOM. This is required before you can do anything.

Logoff

Method

logs user off. This has to be done at the end of your program. If you fail to do this, you will get an out of memory error next time you run the program. Quitting the BASIC environment will clear this.

 

2. Folder Objects (Ifolder)

This object is used to get the collection of items.

set taskItems=tasks.items

Name

Type

Notes

Items

property

Gets the Items Object collection.

 

3. Items Object: (IPOutlookItemCollection)

This object is used to access the individual items. The items are different objects, depending on the folder they come from. They are ICity, IContact, ITask and IAppointment.

for i=1 to taskItems.count
set taskItem=taskItems.item(i)
print taskItem.subject
next

 

Name

Type

Notes

Item(i)

method

returns element i of the Items Object

Count

property

the number of items in the Items Object

IncludeRecurrances

property

Appointments only. Include all recurrances of this item? Could be infinite!

Add

method

create a new item. Does not get kept until you do a Save

Remove(i)

method

remove item i

Sort

method

See Micosoft docs

Find

method

See Micosoft docs

FindNext

method

See Micosoft docs

Save

method

save the current item

Delete

method

delete the current item

Copy

method

make a copy of the current item

Display

method

display the current item

 

 

4a. Item Object: ICity

The ICity Object has the following properties:

Print cityItem.airportcode
CityItem.areaCode="416"

 

Property

Type

AirportCode

String

AreaCode

String

Country

String

CountryPhoneCode

String

InROM

Boolean (read only)

Latitude

long

Longitude

long

Name

String

TimezoneIndex

long

 

4b. Item Object: IContact

Property

Type

Anniversary

Date

AssistantName

String

AssistantTelephoneNumber

String

Birthday

Date

Body

String

Business2TelephoneNumber

String

BusinessAddressCity

String

BusinessAddressCountry

String

BusinessAddressPostalCode

String

BusinessAddressState

String

BusinessAddressStreet

String

BusinessFaxNumber

String

BusinessTelephoneNumber

String

CarTelephoneNumber

String

Categories

String

Children

String

CompanyName

String

Department

String

Email1Address

String

Email2Address

String

Email3Address

String

FileAs

String

FirstName

String

Home2TelephoneNumber

String

HomeAddressCity

String

HomeAddressCountry

String

HomeAddressPostalCode

String

HomeAddressState

String

HomeAddressStreet

String

HomeFaxNumber

String

HomeTelephoneNumber

String

JobTitle

String

LastName

String

MiddleName

String

MobileTelephoneNumber

String

OfficeLocation

String

OtherAddressCity

String

OtherAddressCountry

String

OtherAddressPostalCode

String

OtherAddressState

String

OtherAddressStreet

String

PagerNumber

String

RadioTelephoneNumber

String

Spouse

String

Suffix

String

Title

String

WebPage

String

 

4C. Item Object: ITask

Check Microsoft's docs for information on ITask specific methods.

Property

Type

Body

String

Categories

String

Complete

Boolean

DateCompleted

Date read only

DueDate

Date

Importance

long (0,1,2)

IsRecurring

Boolean read only

ReminderOptions

long

ReminderSet

Boolean

ReminderSoundFile

String

ReminderTime

Date

Sensitivity

long (0 or 2)

StartDate

Date

Subject

String

TeamTask

Boolean

 

 

4D. Item Object: IAppointment

Check Microsoft documentation for IAppointment specific methods.

Property

Type

Subject

String

Location

String

Categories

String

Start

Date

Duration

long

End

Date

AllDayEvent

Boolean

IsRecurring

Boolean read only

MeetingStatus

Long read only

Sensitivity

0=Normal, 1=Private

BusyStatus

0=Free, 1=Tentative, 2=Busy, 3=OutOfOffice

ReminderSet

Boolean

ReminderSoundFile

String

ReminderOptions

long

ReminderMinutesBeforeStart

long

Body

String

 

 

Sample Code 

REM Demonstrate use of Pocket Outlook
addobject "pocketoutlook.application","pol"
pol.logon()
on error resume next
print "Poom Version:" & pol.version
print "Current City:" & pol.currentCityIndex
print "Home City:" & pol.HomeCity.name
print "Visiting City:" & pol.VisitingCity.name
print "Partnered with Outlook? " & pol.outlookCompatible

'get tasks
set tasks=pol.getdefaultfolder(13)
set taskItems=tasks.items
print "Tasks (" & taskItems.count & ")"

for i=1 to taskItems.count
  set taskItem=taskItems.item(i)
  print taskItem.subject
next

'create a new task
set newTask=taskItems.add
print typename(newtask)
newTask.subject="New task created by NS Basic/CE"
newTask.save

'get contacts
set contacts=pol.getdefaultfolder(10)
set contactItems=contacts.items
print "Contacts (" & contactItems.count & ")"

for i=1 to contactItems.count
  set contactItem=contactItems.item(i)
  print contactItem.lastname
next

'get appointments
set appointments=pol.getdefaultfolder(9)
set appointmentItems=appointments.items
print "Appointments (" & appointmentItems.count & ")"

for i=1 to appointmentItems.count
  set appointmentItem=appointmentItems.item(i)
  print appointmentItem.subject
next

'get cities
set cities=pol.getdefaultfolder(101)
set cityItems=cities.items
print "Cities (" & cityItems.count & ")"

for i=1 to 10
  set cityItem=cityItems.item(i)
  print cityItem.name
next

pol.logoff