IItem::Copy

4/8/2010

The Copy method creates a copy of a PIM item.

Syntax

HRESULT Copy(
   IItem ** ppolCopy
);

Parameters

  • ppolCopy
    [out] Reference to the copied PIM IItem object.

Return Value

This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    The method completed successfully.

Code Example

The following code example demonstrates how to use Copy. In the example, pItemCopy contains a copy of the IItem object. All of the properties are copied, including named properties. Named properties created with the PIM_DONTREPLICATE set are not copied though. For more information, see GetIDsFromNames Flags.

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.

HRESULT CopyExample(IItem *pItem)
{
    HRESULT hr = E_FAIL;
    IItem *pItemCopy = NULL;

    hr = pItem->Copy(&pItemCopy);

    if(NULL != pItemCopy)
        pItemCopy->Release();

    return hr;
}

Remarks

If you modify an item's BodyInk binary stream data (that is, the PIMPR_BODY_BINARY property), you must save the item before copying it—otherwise that property will not be copied.

Streams behave differently depending on whether the item has been saved. You must call IStream::Commit(0) (note the parameter of zero) on the stream before calling IItem::Save on the item. If you do not, then the Item might not be saved. This depends on whether you have previously saved the item.

Both PIMPR_BODY_TEXT and PIMPR_BODY_BINARY are always copied.

Requirements

Header pimstore.h
Library Pimstore.lib
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Reference

IItem

Other Resources