Share via


IRecipients::Add

Send Feedback

The Add method adds a person to the recipient list for a meeting request. After you add the recipient, you must set the recipient's Address property.

Syntax

HRESULT Add(
  BSTR pwszName,
  IRecipient ** pRecipient
);

Parameters

  • pwszName
    [in] Reference to a null-terminated Unicode string with the display name for the recipient.
  • pRecipient
    [out] Reference to the new recipient.

Return Values

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 creates a meeting and sends it to three recipients.

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 CreateMeetingRequest(IPOutlookApp * polApp)
{
    IRecurrencePattern * pRec;
    IAppointment * pAppt;
    IRecipients * pRecipients;
    IRecipient * pRecipient;
    VAR_BOOL bResolved

    // Add a new appointment.
    polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);

    // Set the subject on the appointment.
    pAppt->put_Subject(TEXT("Recurring Appointment"));

    // Convert Monday, 4/5/9 at 10:00 am to a DATE.
    SYSTEMTIME st;
    DATE date;
    memset(&st, 0, sizeof(SYSTEMTIME));
    st.wMonth = 4;
    st.wDay   = 5;
    st.wYear  = 1999;
    st.wHour  = 10;
    polApp->SystemTimeToVariantTime(&st, &date);

    // Set the start date.
    pAppt->put_Start(date);

    // Add recipients.
    pAppt->get_Recipients(&pRecipients);
    pRecipients->Add(TEXT("Kathryn Wilson"), &pRecipient);
    pRecipients->Add(TEXT("Blanca"), &pRecipient);
    pRecipients->Add(TEXT("Robert"), &pRecipient);

    // Resolve the recipients against contacts on the Windows Mobile–based device.
    IPOlRecipient * pRecip2;
    int iRecipientCount;
    pRecipients->get_Count(&iRecipientCount);
    // Count down so that removing recipient does not reorder
    // remaining unresolved recipients.
    for (int i = iRecipientCount; i > 0; i--) {
        pRecipients->Item(i, &pRecipient)
        pRecipient->QueryInterface(IID_IPOlRecipient, (LPVOID*)&pRecip2);
        pRecip2->Resolve(TRUE, &bResolved);
        if (!bResolved)pRecipients->Remove(i);
            pRecip2->Release();
    }

    // Send the meeting request.
    pRecipients->get_Count(&iRecipientCount);
    if (iRecipientCount > 0) pAppt->Send();

    // Release objects.
    pRec->Release();
    pAppt->Release();
    pRecipients->Release();
    pRecipient->Release();
}

Requirements

Pocket PC: Pocket PC 2000 and later
Smartphone: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: pimstore.h
Library: pimstore.lib

See Also

How to: Create a Meeting Request | IRecipients | IRecipient | IPOlRecipient | Pocket Outlook Object Model API Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.