PDA

View Full Version : Accessing POOM - Outlook Contacts, Tasks, etc.


DirectDance
03-14-2007, 11:33 AM
Hi,

this code sharing example should help to access the POOM library (Calendar, Contacts, etc.) wich is build in your PPC.

First of all, thanks to Kornalius who changed the COM accessing in PPL, version 1.22. Please note, that you will need at least V1.22 of PPL to get access to the POOM functionality.

I am using a PPC WM5.0 device. It seems, that the needed dll (pimstore) is installed and started on those devices on default.

If you are running a version less than WM5.0, it could be, that you will need the eVB runtime to get access to the POOM functionality.

To test, if your device is compatible on default, you could do this:


COMObjects(objects$, -1);
ShowMessage("\ActiveX Objects:\n\n" + ListToStr(objects$, #13#10, "", "")+"\n");

The result should include a line:

PocketOutlook.Application,pimstore.dll

or something sililar. If not, get the eVB runtime here: http://msdn.microsoft.com/mobility/windowsmobile/downloads/evb.aspx

This is a .cab file wich can be copied to your device and starting it. It installs plenty of dll´s. I hope, after installing the cab file, you should have a entry "PocketOutlook.Application" because, this is the main handle of POOM. As told before, I could not test it, because the pimstore is installed by default on my device. It would be very nice, if somebody using an older device could respond to this thread and tell us if it is correct.

Ok, now back to the POOM access. I will explain it mainly on using the Contacts folder. But it should work with Calendar, Tasks, etc., too. This is, because the POOM structure is equal in every folder structure. The folder structure is like this (simplified):


- Poom Main Entry
- Folder Contacts
- Contact Items
- Folder Calendar
- Calendar Items
- Folder Tasks
- Folder City
- Folder Infrared


1. Initialize POOM

poom$ = CreateCOMObject("PocketOutlook.Application");

You will get a main handle to the POOM object. This has to be done only once, e.g. after your program was started. At this point, the variable poom$ is containing the handle but no operations on POOM could be done before log into the POOM object.

2. Logon to the POOM Object

poomlogon$ = Invoke(poom$, "logon");

Now you are connected to POOM.
Please, before closing your application, do not forget to logoff from POOM.

Ok, here are a few examples to play with POOM:

3. Create a new Contact

folder$ = Invoke(poom$, "GetDefaultFolder", 10); //Enter the Contacts Folder (10 for contacts)
items$ = GetProperty(folder$, "items"); //Set a handle pointer to the Items object (contacts themselfes)
newContact$ = invoke(items$, "add"); //We would like to ADD a new contact
newContactProp$ = SetProperty(newContact$, "LastName", "Smith"); //Set the LastName variable of POOM to "Smith"
tasksave$ = invoke(newContact$, "save"); //Save the stuff. Without this command, the new contact wont be saved

Of course, you can assign every datafield of POOM using the SetProperty method (LastName, FirstName, etc.. A complete list of the contact properties can be found on the microsoft websites.

At this point I would like to do the same as in point -3-, but creating a new task

4. Create a new Task

folder$ = Invoke(poom$, "GetDefaultFolder", 13);
items$ = GetProperty(folder$, "items");
newTask$ = invoke(items$, "add");
newtasksubject$ = SetProperty(newTask$, "subject", "Go shopping");
tasksave$ = invoke(newTask$, "save");


Almost the same as in the contacts folder ;-)

5. Load / Search for a contact

folder$ = Invoke(poom$, "GetDefaultFolder", 10); //Explained above
items$ = GetProperty(folder$, "items"); //Explained above
SearchContact$ = invoke(items$, "find", "[LastName] >= \"A\""); //Search for Contacts where the Lastname is equal or greater than a letter "A"
ContactOID$ = getproperty(SearchContact$, "oid"); //Get the OID of the first contact found
loadmycontact$ = invoke(poom$, "GetItemFromOid", ContactOID$); //Load the Contact using the OID
name1$ = getproperty(loadmycontact$, "firstname"); //Get the First Name
name2$ = getproperty(loadmycontact$, "lastname"); //Get the Last Name
showmessage(name1$ % ", " % name2$); //Show the result

The "Find" command is very flexible. For more infos about that command, please have a look into the MS Docs.

Get the next data ("find" will only load the first data)

SearchContact$ = invoke(items$, "findnext");
ContactOID$ = getproperty(SearchContact$, "oid");
loadmycontact$ = invoke(poom$, "GetItemFromOid", votest$);
name1$ = getproperty(loadmycontact$, "firstname");
name2$ = getproperty(loadmycontact$, "lastname");
showmessage(name1$ % ", " % name2$);


Puh ..., now my fingers are aching.

I hope, the above listed examples will help you creating great apps using PPL.

There are many other possibilities I have not described here. Of course, you can delete, modify, etc. those items.

You will find tons of examples on the internet how to dodiffrent things using POOM. With the above listed examples it should be an easy one to rewrite any example wich was written for e.g. using eVB to PPL.

A last important sentence: PPL is best!

Cheers,
DirectDance

zehlein
03-14-2007, 05:34 PM
Thx DD - these examples are great!

bmanske
03-14-2007, 06:04 PM
Great examples! Thanks!

matteo.m
03-15-2007, 09:45 AM
Thanks a lot !!

kornalius
03-15-2007, 03:30 PM
Wow, thank you so much for this great tutorial.

Heinz
03-22-2007, 04:53 PM
Thanks a lot, Direct Dance!! That is VERY usefull!

Slither
10-29-2007, 04:15 AM
Will this work on WM6 please?

zehlein
10-30-2007, 02:33 PM
The easiest way would be to try and let us know, I think ;-)

DirectDance
10-30-2007, 03:20 PM
No, it is not working on WM6 and some later versions of WM5.

I can proceed the invokes of poom on those devices until the "item" collection but not further.

MS has changed the access of POOM for their own language but not for others anymore :-(

Slither
11-01-2007, 01:04 AM
I tried it and copied the Initialise and Logon code followed by the Search/Load example then Logged off.

This is what I got.

APP:
MYAPP_WM2003.EXE
FILE:MYAPP_WM2003.EXE
Proc:WINMAIN
Opcode: INVOKE
Char/Line/Offset: 0, 0,
0x00387e64

(WINMAIN)
Access violation at
0x230a8


Is this a common error I made myself or does this mean that WM6 is changed as stated above.

Cheers,

Slither2006. (Using WM06)

[EDIT] : I installed the eVB and found the above error message goes away. But I get the Address Alignment error message instead whenever I try to access the method to add an item. I showmsg'd the folder$ and items$ variables and are being assigned values.

Smok Wawelski
11-27-2007, 06:02 PM
I found some more information about POOM: http://www.devbuzz.com/content/zinc_evb_and_poom_pg1.asp . You can find there explanation of those mysterious numbers (10 for contacts etc..).

Slither
11-29-2007, 03:56 AM
Programmed the app in C# POOM without any issues and didn't run into any of the problems i did with PPL....I'm yet to see someone access POOM from WM06 in PPL...Good luck to those who try.

PointOfLight
11-29-2007, 05:11 AM
Currently you can't access POOM in WM6 through PPL.* Microsoft broke pimstore.dll access part way through the WM5 lifespan, and has apparently decided not to fix it in favor of forcing people to access POOM through .Net.* Unfortunately, PPL does not take advantage of .Net right now.* Does your C# implementation work on pre-WM5 devices?