Export (0) Print
Expand All
Expand Minimize

IContact::Save

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

The Save method saves a Contact item.


HRESULT Save(void);

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.

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

The following code example creates and saves a new Contact.

Aa914242.note(en-us,MSDN.10).gifNote:
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();
}

Headerpimstore.h
LibraryPimstore.lib
Windows Embedded CEWindows CE 2.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

ADD
Show:
© 2014 Microsoft