[This is now documented here: http://msdn.microsoft.com/en-us/library/gg508913.aspx ]

[This API no longer functions in Outlook 2013 - it is Outlook 2010 only]

Development recently asked that I document a few oddball Outlook APIs. Here’s the first – a way to turn the Sender Contact Photo feature on or off in a particular inspector or explorer window. I’ve not tested the code snippet, so any feedback is welcome.

dispidShowSenderPhoto

This method is used to tell an Outlook inspector or explorer window that we do or do not wish to have Sender Contact Photos displayed in that particular window. This setting does not persist across Outlook sessions, and does not carry from one inspector or explorer to another. The default setting is True/On. On means that if a photo is present, it will be shown. However, a placeholder photo will not be shown if no photo is present.

Syntax

Given either an Explorer or Inspector object pointer, use QueryInterface to obtain an IDispatch interface pointer. Then call IDispatch::Invoke with dispidShowSenderPhoto and the desired value.

This method takes one Boolean argument. Use VARIANT_TRUE to turn it on, and VARIANT_FALSE to turn it off.

Registry Key Interaction

This setting works in conjunction with the TurnOffPhotograph policy key (Outlook 2010 only) as well as the older ShowContactPicture registry key (Outlook 2007 and up). Here’s a grid which shows how these registry keys and dispidShowSenderPhoto interact:

dispidShowSenderPhoto TurnOffPhotograph ShowContactPicture Will photos display 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

Sample Code

#define dispidShowSenderPhoto 0xF0D0
 
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);
}

Enjoy!