[Cf. Skills] Use pocketoutlook in managed code to easily find and add Contacts

Source: Internet
Author: User
Abstract: Although I sometimes get bored with C # And this framework-based development model, or. net Framework is a bit difficult, but sometimes you have to lament how easy it makes our development. For example, the contacts who Access Windows Mobile.
Keywords
Poom, Windows Mobile, pocketoutlook, contacts,. NET Compact framework, C #, C ++

A friend asked about poom two days ago. In fact, some examples of the SDK have been clearly written below. After Windows Mobile 5Microsoft. windowsmobile. pocketoutlookNamespace. This makes poom programming very simple. It is also used to obtain contacts. We will see the differences between using VC ++ and VC. Next let's take a look at using managed serviceCodeHow C # is implemented.
First, create an outlook session instance: Outlooksession mysession= NewOutlooksession ();

Then access the contacts attributes directly: Int Index =   0 ;
Contact contact =   New Contact ();

// Add a contact if the current contact is zero
If (Session. Contacts. Items. Count <=   0 )
{
Contact. firstname= "Contact";
Contact. lastname= "With picture";
Session. Contacts. Items. Add (contact );
}
Else
{
Contact=Session. Contacts. items [0];
}
// Then you can do what you want to do with your contact object.

How are you doing? Simple :-)

PS: For details about pocketoutlook contact, refer toAddpicturetocontactExample.

Let's take a look at how to create a session to access pocketoutlook in the C ++ smart device project of:
1. Declare An ipoutlookapp interface and initialize the ipoutlookapp pointer.(Note: This is not C #, so Initialization is essential): Ipoutlookapp*Pmypoomapp=NULL;

2. Next, you need to use coinitializeex API to initialize com(Note: poom APIs are a group of Apis Based on COM): Coinitializeex (null,0);

3. Use the cocreateinstance API to create a COM Object for your application Program :

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> cocreateinstance (clsid_application, null, clsctx_inproc_server,
iid_iunknown, ( void ** ) & punknown);

4. Use the QueryInterface method to associate the above COM object with the ipoutlookapp interface. Punknown->QueryInterface (iid_ipoutlookapp ,(Void **)&Pmypoomapp );

5. Finally, you need to use the logon () method to log on to the pocket outlook COM Service: Pmypoomapp->Logon (null );

6. Use the created pmypoomapp to retrieve the contact folder (default number: 10 ):

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> ifolder * pfolder;
pmypoomapp -> getdefaultfolder (10, & pfolder);

7. Declare a set of generic PIM items to hold the contacts obtained later: Ipoutlookitemcollection*Pgenericitems;
Pfolder->Get_items (&Pgenericitems)

8. Get contacts Icontact * Pcontact = NULL;
Int Len;
Pgenericitems -> Get_count ( & Len );
For ( Int I = 0 ; I < Len; I ++ ) {
Pgenericitems->Item (I,&Pcontact );
}

 
--!!! This is indeed a little troublesome. You can refer toPoommasterIn this directory:
?? \ Program Files \ Windows Mobile 5.0 SDK \ samples \ pocketpc \ CPP \ Win32 \ poommaster

In the futureArticlePocketoutlook programming will be detailed. Finally, I would like to thank the. NET CF team for making development for. Net programmers simple and efficient :-)

Enjoy!

freesc Huang
yellow season and winter @ HUST
2008/4/9

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.