IContact::Save

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The Save method saves a Contact item.

Syntax

HRESULT Save(void);

Return Value

Upon successful completion, this method returns the standard HRESULT value S_OK, else it returns the following:

  • E_FAIL
    The Contact item could not be saved to the database.
  • E_INVALIDARG
    The argument is not valid.
  • E_OUTOFMEMORY
    Ran out of memory.
  • E_UNEXPECTED
    An unexpected error occurred.
  • S_FALSE
    This can occur for several reasons. For example, if the Contact item cannot be found, if the database cannot be updated, or if the FileAs information cannot be generated.

Remarks

To save a contact, you must specify at least one of the following four properties: FirstName, LastName, CompanyName, and FileAs.

Code Example

The following code example creates and saves a new Contact.

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.

void SaveContact(IPOutlookApp * polApp)
{
    IContact                * pContact;
    IFolder                 * pFolder;
    IPOutlookItemCollection * pItems;

    // Create a new contact.
    polApp->GetDefaultFolder(olFolderContacts, &pFolder);
    pFolder->get_Items(&pItems);
    pItems->Add(&pContact);

    pContact->put_FirstName(TEXT("Brian"));
    pContact->put_LastName(TEXT("Fleming"));
    pContact->put_Company(TEXT("Microsoft"));
    pContact->put_FileAs(TEXT("Fleming"));

    // Save the new contact.
    pContact->Save();

    // Release objects.
    pContact->Release();
    pFolder->Release();
    pItems->Release();
}

Requirements

Header pimstore.h
Library Pimstore.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Tasks

Creating a PIM Item

Reference

Pocket Outlook Object Model Interfaces

Other Resources

Pocket Outlook Object Model Enumerations