Extend Pocket Outlook .net Wrapper

M

Mozzak

Dear Readers,

I am currently trying to understand how to access the
pocket outlook data from a .net application. I have found
the example for POOM written in C#
(seehttp://www.gotdotnet.com/team/netcf/Samples.aspx)
which basically shows what dlls there are and how to
access them. However this example (I guess written by
microsoft) access all data that bring a string back for
example the subject of an appointment:

public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject(this.RawItemPtr,
value));
}
} // Subject

....
...
[ DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self,
String zBody);


I wonder now how to access Date type related data like the
Start date of the appointment.

I tried the following without success:

public String Start
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Start(this.RawItemPtr, ref bz);
String zStart = null;

try
{
PocketOutlook.CheckHRESULT(hResult);

zStart = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zStart;

}
set
{
//PocketOutlook.CheckHRESULT(do_put_Categories
(this.RawItemPtr, value));
}
}

.....

[DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_get_Start")]
private static extern int do_get_Start (IntPtr self, ref
IntPtr pStart);

By doing that I get an error: A native exception occured.
Exception code 0x80000002

Any idea how to extend this do get date types back ?

Thanks alot,
Michael
 
P

Peter Foot [MVP]

You cannot marshal the Date type between native code and .NETCF because it
is larger than 4bytes. The marshaller in the Compact Framework supports only
4byte and smaller intrinsic types Int32, UInt32 and smaller.
Instead you can pass pointers to date values to overcome this limitation -
pointers are 32bit integers. This will require work on the native dll to
pass the values as pointers rather than by value, and in the .NET part to
pass ref double to and from the native dll. These are not implemented in the
bare bones sample from Microsoft which is intended to show a starting point
for COM interop.
Note also that the date types used by POOM are double values which you will
need to convert to and from a .net DateTime type.

We have a complete implementation of POOM in our PocketOutlook InTheHand
library which may be of interest - http://www.inthehand.com/dotnet/poom/
This adds additional functionality including Pocket Streets integration and
full support for all Pocket PC platforms and Smartphone 2003.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Mozzak said:
Dear Readers,

I am currently trying to understand how to access the
pocket outlook data from a .net application. I have found
the example for POOM written in C#
(seehttp://www.gotdotnet.com/team/netcf/Samples.aspx)
which basically shows what dlls there are and how to
access them. However this example (I guess written by
microsoft) access all data that bring a string back for
example the subject of an appointment:

public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject(this.RawItemPtr,
value));
}
} // Subject

...
..
[ DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self,
String zBody);


I wonder now how to access Date type related data like the
Start date of the appointment.

I tried the following without success:

public String Start
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Start(this.RawItemPtr, ref bz);
String zStart = null;

try
{
PocketOutlook.CheckHRESULT(hResult);

zStart = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zStart;

}
set
{
//PocketOutlook.CheckHRESULT(do_put_Categories
(this.RawItemPtr, value));
}
}

....

[DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_get_Start")]
private static extern int do_get_Start (IntPtr self, ref
IntPtr pStart);

By doing that I get an error: A native exception occured.
Exception code 0x80000002

Any idea how to extend this do get date types back ?

Thanks alot,
Michael
 
M

Mozzak

Hi Peter,

thanks for your answer. The library seems to do what I
plan to do but before I go ahead with inthehand let me ask
you one more question. Is it possible to extend the data
model of Outlook and to access the new fields in the
library ?
In other words, to link an outlook contact for example
with an account in a backoffice system, new fields would
be needed that reference these ids. Doing this on Desktop
Outlook is possible but will this new field be sync'd to
the IPAQ and will the library be able to read and write
this field as well ?

Thanks again,
Michael
-----Original Message-----
You cannot marshal the Date type between native code and .NETCF because it
is larger than 4bytes. The marshaller in the Compact Framework supports only
4byte and smaller intrinsic types Int32, UInt32 and smaller.
Instead you can pass pointers to date values to overcome this limitation -
pointers are 32bit integers. This will require work on the native dll to
pass the values as pointers rather than by value, and in the .NET part to
pass ref double to and from the native dll. These are not implemented in the
bare bones sample from Microsoft which is intended to show a starting point
for COM interop.
Note also that the date types used by POOM are double values which you will
need to convert to and from a .net DateTime type.

We have a complete implementation of POOM in our PocketOutlook InTheHand
library which may be of interest - http://www.inthehand.com/dotnet/poom/
This adds additional functionality including Pocket Streets integration and
full support for all Pocket PC platforms and Smartphone 2003.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Mozzak said:
Dear Readers,

I am currently trying to understand how to access the
pocket outlook data from a .net application. I have found
the example for POOM written in C#
(seehttp://www.gotdotnet.com/team/netcf/Samples.aspx)
which basically shows what dlls there are and how to
access them. However this example (I guess written by
microsoft) access all data that bring a string back for
example the subject of an appointment:

public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject (this.RawItemPtr,
value));
}
} // Subject

...
..
[ DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self,
String zBody);


I wonder now how to access Date type related data like the
Start date of the appointment.

I tried the following without success:

public String Start
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Start(this.RawItemPtr, ref bz);
String zStart = null;

try
{
PocketOutlook.CheckHRESULT(hResult);

zStart = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zStart;

}
set
{
//PocketOutlook.CheckHRESULT(do_put_Categories
(this.RawItemPtr, value));
}
}

....

[DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_get_Start")]
private static extern int do_get_Start (IntPtr self, ref
IntPtr pStart);

By doing that I get an error: A native exception occured.
Exception code 0x80000002

Any idea how to extend this do get date types back ?

Thanks alot,
Michael


.
 
P

Peter Foot [MVP]

It is not possible to add custom fields directly into Pocket Outlook and
have them sync with existing custom fields in Desktop Outlook. It is however
possible to maintain the "extra" data in a separate database table or
datafile of some sort - you can link it to the basic outlook contacts using
a unique field such as the FileAs property or Oid of the contact. However
you would need to write your own code to synchronise this custom data with
the desktop outlook object model.

You could write out a csv or xml file containing your key field (e.g.
FileAs) and your custom properties and copy it to the device using RAPI
(Remote API - see OpenNETCF Communication library
http://www.opennetcf.org/communication.asp). Then write your device side
application to load the csv or xml data and augment it with the full contact
data from the internal pocket outlook store using your own custom forms.
Upon docking the device it is possible to configure ActiveSync to start your
custom desktop side application which will synchronise updates in your
custom fields - you can check for changes on device or desktop data and
synchronise. Alternatively you could write an activesync provider to
integrate with activesync itself but this cannot currently be done with .NET
CF code.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Mozzak said:
Hi Peter,

thanks for your answer. The library seems to do what I
plan to do but before I go ahead with inthehand let me ask
you one more question. Is it possible to extend the data
model of Outlook and to access the new fields in the
library ?
In other words, to link an outlook contact for example
with an account in a backoffice system, new fields would
be needed that reference these ids. Doing this on Desktop
Outlook is possible but will this new field be sync'd to
the IPAQ and will the library be able to read and write
this field as well ?

Thanks again,
Michael
-----Original Message-----
You cannot marshal the Date type between native code and .NETCF because it
is larger than 4bytes. The marshaller in the Compact Framework supports only
4byte and smaller intrinsic types Int32, UInt32 and smaller.
Instead you can pass pointers to date values to overcome this limitation -
pointers are 32bit integers. This will require work on the native dll to
pass the values as pointers rather than by value, and in the .NET part to
pass ref double to and from the native dll. These are not implemented in the
bare bones sample from Microsoft which is intended to show a starting point
for COM interop.
Note also that the date types used by POOM are double values which you will
need to convert to and from a .net DateTime type.

We have a complete implementation of POOM in our PocketOutlook InTheHand
library which may be of interest - http://www.inthehand.com/dotnet/poom/
This adds additional functionality including Pocket Streets integration and
full support for all Pocket PC platforms and Smartphone 2003.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Mozzak said:
Dear Readers,

I am currently trying to understand how to access the
pocket outlook data from a .net application. I have found
the example for POOM written in C#
(seehttp://www.gotdotnet.com/team/netcf/Samples.aspx)
which basically shows what dlls there are and how to
access them. However this example (I guess written by
microsoft) access all data that bring a string back for
example the subject of an appointment:

public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject (this.RawItemPtr,
value));
}
} // Subject

...
..
[ DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self,
String zBody);


I wonder now how to access Date type related data like the
Start date of the appointment.

I tried the following without success:

public String Start
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Start(this.RawItemPtr, ref bz);
String zStart = null;

try
{
PocketOutlook.CheckHRESULT(hResult);

zStart = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zStart;

}
set
{
//PocketOutlook.CheckHRESULT(do_put_Categories
(this.RawItemPtr, value));
}
}

....

[DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_get_Start")]
private static extern int do_get_Start (IntPtr self, ref
IntPtr pStart);

By doing that I get an error: A native exception occured.
Exception code 0x80000002

Any idea how to extend this do get date types back ?

Thanks alot,
Michael


.
 
M

mozzak

Peter,

I meant Pocket Access not Pocket Outlook.

Michael
-----Original Message-----
Hi Peter,

thanks for your advice. Besides programming a data
communication do you have experience in using pocket
outlook which to my knowledge synchronizes over Active
Sync automatically.
You mentioned custom forms for outlook. How do you get them
to the PDA ? is there somewhere a good tutorial how to
program custom forms for the PDA ?

I read more about your library. How would be th cost
structure if my cooperation would decide to use it ?
One tome cost or licensing ?

Thanks again,
Michael

-----Original Message-----
It is not possible to add custom fields directly into Pocket Outlook and
have them sync with existing custom fields in Desktop Outlook. It is however
possible to maintain the "extra" data in a separate database table or
datafile of some sort - you can link it to the basic outlook contacts using
a unique field such as the FileAs property or Oid of the contact. However
you would need to write your own code to synchronise
this
custom data with
the desktop outlook object model.

You could write out a csv or xml file containing your
key
field (e.g.
FileAs) and your custom properties and copy it to the device using RAPI
(Remote API - see OpenNETCF Communication library
http://www.opennetcf.org/communication.asp). Then write your device side
application to load the csv or xml data and augment it with the full contact
data from the internal pocket outlook store using your own custom forms.
Upon docking the device it is possible to configure ActiveSync to start your
custom desktop side application which will synchronise updates in your
custom fields - you can check for changes on device or desktop data and
synchronise. Alternatively you could write an activesync provider to
integrate with activesync itself but this cannot currently be done with .NET
CF code.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Mozzak said:
Hi Peter,

thanks for your answer. The library seems to do what I
plan to do but before I go ahead with inthehand let me ask
you one more question. Is it possible to extend the data
model of Outlook and to access the new fields in the
library ?
In other words, to link an outlook contact for example
with an account in a backoffice system, new fields would
be needed that reference these ids. Doing this on Desktop
Outlook is possible but will this new field be sync'd to
the IPAQ and will the library be able to read and write
this field as well ?

Thanks again,
Michael

-----Original Message-----
You cannot marshal the Date type between native code
and .NETCF because it
is larger than 4bytes. The marshaller in the Compact
Framework supports only
4byte and smaller intrinsic types Int32, UInt32 and
smaller.
Instead you can pass pointers to date values to overcome
this limitation -
pointers are 32bit integers. This will require work on
the native dll to
pass the values as pointers rather than by value, and in
the .NET part to
pass ref double to and from the native dll. These are not
implemented in the
bare bones sample from Microsoft which is intended to
show a starting point
for COM interop.
Note also that the date types used by POOM are double
values which you will
need to convert to and from a .net DateTime type.

We have a complete implementation of POOM in our
PocketOutlook InTheHand
library which may be of interest -
http://www.inthehand.com/dotnet/poom/
This adds additional functionality including Pocket
Streets integration and
full support for all Pocket PC platforms and Smartphone
2003.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com

Dear Readers,

I am currently trying to understand how to access the
pocket outlook data from a .net application. I have
found
the example for POOM written in C#
(seehttp://www.gotdotnet.com/team/netcf/Samples.aspx)
which basically shows what dlls there are and how to
access them. However this example (I guess written by
microsoft) access all data that bring a string back for
example the subject of an appointment:

public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject
(this.RawItemPtr,
value));
}
} // Subject

...
..
[ DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self,
String zBody);


I wonder now how to access Date type related data like
the
Start date of the appointment.

I tried the following without success:

public String Start
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Start(this.RawItemPtr, ref bz);
String zStart = null;

try
{
PocketOutlook.CheckHRESULT(hResult);

zStart = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}

return zStart;

}
set
{
//PocketOutlook.CheckHRESULT(do_put_Categories
(this.RawItemPtr, value));
}
}

....

[DllImport("PocketOutlook.dll",
EntryPoint="IAppointment_get_Start")]
private static extern int do_get_Start (IntPtr
self,
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top