Pocket Outlook Folders

A Pocket Outlook folder defined by the IFolder interface contains a collection of objects that are specific to the folder type. For example, the Tasks folder contains only ITask items. To get the pointer for an IFolder interface, you use the IPOutlookApp::GetDefaultFolder() function.

Once you have the pointer to a particular IFolder interface, you can then access, modify, and delete Pocket Outlook items. Table 10.4 describes the method supported by each IFolder interface (for Contacts, Calendar, and Tasks).

Table 10.4. IFolder Method

Method

Description

ReceiveFromInfrared()

Starts to receive items over infrared

Table 10.5 describes the properties supported by the IFolder interface.

Table 10.5. IFolder Properties

Property

Get/Put

Description

Application

Get

Returns a pointer to the IPOutlookApp interface

DefaultItemType

Get

Returns the folder type (except for the infrared folder)

Items

Get

Returns an IPOutlookItemCollection interface for the items in the folder

The most common use for a folder is to get access to the collection object for the items that it is storing. To do so, use the following function:

 HRESULT IFolder::get_Items(IPOutlookItemCollection   **ppolItems); 

The only parameter that the function takes is a pointer to an IPOutlookItemCollection interface pointer. Once this pointer has been returned, you can begin to sort and access individual Outlook data items.

You can get the collection of Outlook items in the following manner:

 // Get the calendar items IPOutlookItemCollection *pICalItems = NULL; hr = pIFolder->get_Items(&pICalItems); if(FAILED(hr)) {    pIFolder->Release();    return FALSE; } // Do something with the items TCHAR tchMsg[1024] = TEXT("\0"); int nCount = 0; pICalItems->get_Count(&nCount); wsprintf(tchMsg, TEXT("There are %d items"), nCount); MessageBox(NULL, tchMsg, TEXT("Calendar"), MB_OK); // Clean up if(pICalItems)    pICalItems->Release(); 

Sending and Receiving Items over Infrared

In addition to the three standard folders Contacts, Tasks, and Calendar there is a special fourth folder that doesn't contain any actual Outlook items. The Infrared folder is used for sending items over the IR port to another Pocket PC device. You can get a pointer to the Infrared folder just as you do for other folders, by using the IPOutlookApp::GetDefaultFolder() function, as shown in the following example:

 // Infrared IFolder *pIRFolder = NULL; hr = pOlApp->GetDefaultFolder(olFolderInfrared, &pIRFolder); if(FAILED(hr)) {    OutputDebugString(TEXT("Could not get the infrared        folder"));    return FALSE; } if(pIRFolder)    pIRFolder->Release(); 

Table 10.6 describes the additional methods supported by the IFolder interface, which are used when working with the Infrared folder.

Table 10.6. IFolder Methods for the Infrared Folder

Method

Description

AddItemToInfraredFolder()

Adds a list of items to be sent over infrared

SendToInfrared()

Sends the items in the folder to the IR port

You can add any type of item that is supported by Pocket Outlook to the folder by calling into the IFolder::AddItemToInfraredFolder() method, which is defined as follows:

 HRESULT IFolder::AddItemToInfraredFolder(int olItem,   IDispatch *polItem); 

The first parameter should specify the type of item that is being added, and can be set to olAppointmentItem, olContactItem or olTaskItem. The polItem parameter should point to the actual item that is being added.

After you have added all of the contacts, appointments, and tasks that you want to send, you can simply instruct the folder to transmit them by calling the following function:

 HRESULT IFolder::SendToInfrared(); 

The following example shows how to use these functions to send a Pocket Outlook appointment item over infrared:

 // Get the calendar items IPOutlookItemCollection *pICalItems = NULL; hr = pIFolder->get_Items(&pICalItems); if(FAILED(hr)) {    pIFolder->Release();    return FALSE; } // Get an item IAppointment *pICalEntry = NULL; hr = pICalItems->Item(1, (IDispatch **)&pICalEntry); // Send it to IR if(SUCCEEDED(hr)) {    pIRFolder->AddItemToInfraredFolder(olAppointmentItem,        pICalEntry);    pIRFolder->SendToInfrared(); } 

When you want to receive Outlook data over the infrared port, there are two different methods that you can use:

  1. The IPOutlookApp::ReceiveFromInfrared() method handles any type of Outlook item and places it in the correct folder when it is received.

  2. The IFolder::ReceiveFromInfrared() method handles only receiving items of the correct folder type. For example, if you called this function from the Contacts folder, any Task items sent would be rejected.

To set up your application to receive data over the infrared port, you can do the following:

 // Infrared IFolder *pIRFolder = NULL; hr = pOlApp->GetDefaultFolder(olFolderInfrared, &pIRFolder); if(FAILED(hr)) {    OutputDebugString(TEXT("Could not get the infrared        folder"));    return FALSE; } // Receive pIRFolder->ReceiveFromInfrared(); if(pIRFolder)    pIRFolder->Release(); 


Pocket PC Network Programming
Pocket PC Network Programming
ISBN: 0321133528
EAN: 2147483647
Year: 2005
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net