Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Adding a PIM item to the Outlook Mobile database involves calling the item's Savemethod.
The Outlook Mobile database consists of three separate PIM item lists contained in the three Default Folders: the Appointments folder, the Tasks folder, and the Contacts folder.
To add a Contact to the Contacts folder
-
Create an instance of the Outlook Mobile application object and then use it to establish a POOM session. For more information, see Establishing a POOM Session.
-
Create a PIM item. For more information, see Creating a PIM Item.
-
Declare a reference to a generic PIM item collection, as follows:
Copy Code IPOutlookItemCollection *pItems;
-
Declare a reference to a generic PIM item folder:
Copy Code IFolder *pFolder;
-
Use the generic PIM item folder to get the Contacts folder:
Copy Code polApp->GetDefaultFolder(olFolderContacts, &pFolder);
-
Use the Contacts folder to get the collection of Contact items:
Copy Code pFolder->get_Items(&pItems)
-
Create a new Contact item:
Copy Code pItems->Add(&pContact)
-
Initialize the new Contact item's data members:
Copy Code pContact->put_FirstName(TEXT("Michael")); pContact->put_LastName(TEXT("Angelo")); pContact->put_Company(TEXT("Microsoft")); pContact->put_FileAs(TEXT("Angelo"));
-
Save the new Contact item to the database:
Copy Code pContact->Save();
Example
The following code example demonstrates how to add a new Contactobject to the Contacts folder.
Note: |
---|
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them. |
Copy Code | |
---|---|
void AddNewContact(IPOutlookApp *polApp) { IPOutlookItemCollection * pItems; IFolder * pFolder; IContact * pContact; hr = polApp->GetDefaultFolder(olFolderContacts, &pFolder); hr = pFolder->get_Items(&pItems) hr = pItems->Add(&pContact) hr = pContact->put_FirstName(TEXT("Michael")); hr = pContact->put_LastName(TEXT("Angelo")); hr = pContact->put_Company(TEXT("Microsoft")); hr = pContact->put_FileAs(TEXT("Angelo")); hr = pContact->Save(); } |
To make the code example easier to read, security checking and error handling are not included.
This code example should not be used in a release configuration unless it has been modified to include them.
Compiling the Code
- Include Header File: PimStore.h
- Linker Dependency: PimStore.lib
See Also
Reference
OlDefaultFoldersOther Resources
Pocket Outlook Object Model Common TasksPocket Outlook Object Model Application Development