How to: Specify Whether to Display a Contact's Picture in Outlook (Outlook 2010 Auxiliary Reference)

This topic shows how to use the dispidShowSenderPhoto dispatch ID to invoke the corresponding method on a Microsoft Outlook Explorer or Inspector object, to specify whether to display a contact’s picture in the explorer or inspector window, according to a Boolean argument. Specifying VARIANT_TRUE as the argument turns on the display, and VARIANT_FALSE turns off the display.

Given a pointer to an Explorer or Inspector object, you can use the IUnknown::QueryInterface method to obtain an IDispatch interface pointer. The function in this topic, SetSenderContactPhoto, accepts two input parameters:

  • inspector—An _InspectorPtr value.

  • showSenderContactPhoto—A Boolean value that specifies whether to display contacts' pictures.

SetSenderContactPhoto calls the IDispatch::Invoke method—specifying dispidShowSenderPhoto as the argument for the dispIdMember parameter, and using showSenderContactPhoto to form the argument for the pDispParams parameter—to turn on or off the display according to the value of showSenderContactPhoto.

void SetSenderContactPhoto(_InspectorPtr inspector, bool showSenderContactPhoto)
{ 
    CComVariant cv;
    IDispatchPtr spdisp;
    DISPPARAMS dispparams;
    EXCEPINFO excepinfo = {0};
    spdisp = inspector;
    cv = showSenderContactPhoto ? VARIANT_TRUE : VARIANT_FALSE;
    dispparams.rgvarg = &cv;
    dispparams.cArgs = 1;
    dispparams.rgdispidNamedArgs = NULL;
    dispparams.cNamedArgs = 0;
    spdisp->Invoke(dispidShowSenderPhoto,
        IID_NULL,
        0,
        DISPATCH_METHOD,
        &dispparams,
        NULL,
        &excepinfo,
        NULL);
}

This setting does not persist across Outlook sessions and does not carry from one inspector or explorer to another. The default setting is to turn on the display. This means that if a picture is present, it is displayed. However, if no picture is present, no placeholder picture is displayed.

This setting works in conjunction with the TurnOffPhotograph policy key as well as the older ShowContactPicture registry key. The TurnOffPhotograph policy key was introduced in Microsoft Outlook 2010, and ShowContactPicture registry key was introduced in Microsoft Office Outlook 2007. The following table shows how these registry keys and dispidShowSenderPhoto interact. This setting does not turn on the display if administrator policy (TurnOffPhotograph policy key) or user preference (ShowContactPicture registry key) turns off the display. For more information about the TurnOffPhotograph policy key, see How to manage the Outlook Social Connector by using Group Policy. For more information about the ShowContactPicture registry key, see Deploying additional registry values in the Office Customization Tool for Outlook 2007.

Argument for method represented by dispidShowSenderPhoto TurnOffPhotograph policy key ShowContactPicture registry key Is picture displayed if present?

True

0 or not set

1 or not set

Yes

True

0 or not set

0

No

True

1

1 or not set

No

True

1

0

No

False

0 or not set

1 or not set

No

False

0 or not set

0

No

False

1

1 or not set

No

False

1

0

No

See also

Constants (Exported Outlook APIs)