IMAPISupport::NewEntry

Applies to: Outlook 2013 | Outlook 2016

Adds a new recipient directly to an address book container or to the recipient list of an outgoing message.

HRESULT NewEntry(
  ULONG_PTR ulUIParam,
  ULONG ulFlags,
  ULONG cbEIDContainer,
  LPENTRYID lpEIDContainer,
  ULONG cbEIDNewEntryTpl,
  LPENTRYID lpEIDNewEntryTpl,
  ULONG FAR * lpcbEIDNewEntry,
  LPENTRYID FAR * lppEIDNewEntry
);

Parameters

ulUIParam

[in] A handle to the parent window of the dialog box.

ulFlags

[in] Reserved; must be zero.

cbEIDContainer

[in] The byte count in the entry identifier pointed to by the lpEIDContainer parameter.

lpEIDContainer

[in] A pointer to the entry identifier of the container to receive the new entry. If cbEIDContainer is 0 and lpEIDContainer is NULL, NewEntry creates a one-off entry identifier that is the same type as is generated by a call to the IMAPISupport::CreateOneOff method.

cbEIDNewEntryTpl

[in] The byte count in the entry identifier pointed to by the lpEIDNewEntryTpl parameter.

lpEIDNewEntryTpl

[in] A pointer to the entry identifier of the template to be used to create the new entry. If cbEIDNewEntryTpl is 0 and lpEIDNewEntryTpl is NULL, NewEntry displays a dialog box that enables the user to select from a list of templates for adding new entries.

lpcbEIDNewEntry

[out] A pointer to the byte count in the entry identifier pointed to by the lppEIDNewEntry parameter.

lppEIDNewEntry

[out] A pointer to a pointer to the entry identifier of the newly created entry.

Return value

S_OK

The new entry was successfully created.

Remarks

The IMAPISupport::NewEntry method is implemented for address book provider support objects. Address book providers call NewEntry to create a new address book entry to be added directly into a container or to be used to address an outgoing message.

Notes to callers

If you want the new entry to be added to a specific container, set lpEIDContainer to the container's entry identifier and cbEIDContainer to the byte count in the entry identifier.

If you want the new entry to be added to the recipient list of an outgoing message, set lpEIDContainer to NULL and cbEIDContainer to 0.

If you want to allow the user of a client application to select the type of entry to be created, pass 0 in cbEIDNewEntryTpl and NULL in lpEIDNewEntryTpl. NewEntry displays the MAPI one-off table, a list of templates that MAPI and each of the address book providers in the session support. Each template can create a recipient entry for one or more address types.

If you want to retain the entry identifier of the new entry, pass valid pointers in the lpcbEIDNewEntry and lppEIDNewEntry parameters. You are responsible for freeing this entry identifier when you are finished with it by calling the MAPIFreeBuffer function.

To use a particular template to add a new entry to a modifiable container, use the following procedure:

  1. Call the IMAPISupport::OpenEntry method to open the destination container, and set the lpEntryID parameter to the entry identifier of the container.

  2. Call the destination container's IMAPIProp::OpenProperty method, and set the ulPropTag parameter to PR_CREATE_TEMPLATES (PidTagCreateTemplates) and the lpiid parameter to IID_IMAPITable. The container will return a one-off table that lists all of the templates that it supports for creating new entries.

  3. Retrieve the row that represents the template for the particular type of entry you want to create. The PR_ADDRTYPE (PidTagAddressType) column indicates the address type that is supported by the template.

  4. Call IMAPISupport::NewEntry and set the lpEIDNewEntryTpl parameter to the entry identifier of the selected template. The entry identifier is the PR_ENTRYID (PidTagEntryId) column from the template's row in the one-off table. Pass 0 in cbEIDContainer and NULL in lpEIDContainer. Pass a valid pointer in the lppEIDNewEntry parameter if you want to retain the new entry's entry identifier.

See also

IMAPIProp::OpenProperty

IMAPISupport::OpenEntry

PidTagCreateTemplates Canonical Property

IMAPISupport : IUnknown