How to: Specify Whether to Display a Contact's Picture in Outlook
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 true as the argument turns on the display, and false turns off the display. Note that the solution does not require the Outlook object model, but nonetheless, you can use C# code similar to the code sample in this topic to achieve the same in your managed Outlook solution.
Given a pointer to an Explorer or Inspector object, you can use the Object.GetType() method to obtain a System.Type object.
The function in this topic, SetSenderContactPhoto, accepts two input parameters:
Inspector—An InspectorPtr object.
ShowSenderContactPhoto—A Boolean value that specifies whether to display contacts' pictures.
SetSenderContactPhoto constructs the string representation of the dispidShowSenderPhoto dispatch ID as dispidShowSenderPhotoMemberName. SetSenderContactPhoto then calls the Type.InvokeMember method—specifying dispidShowSenderPhoto as the argument for the name parameter and the flag System.Reflection.BindingFlags.InvokeMethod as the argument for invokeAttr, and using ShowSenderContactPhoto to form the argument for the args parameter—to turn on or off the display in an inspector according to the value of ShowSenderContactPhoto.
void SetSenderContactPhoto(object Inspector, bool ShowSenderContactPhoto)
{
Type typeInspector = Inspector.GetType();
string dispidShowSenderPhotoMemberName = String.Format("[DispID={0}]", 0xF0D0);
object[] args = {ShowSenderContactPhoto};
try
{
typeInspector.InvokeMember(dispidShowSenderPhotoMemberName,
System.Reflection.BindingFlags.InvokeMethod,
null,
Inspector,
args);
}
catch(System.Runtime.InteropServices.COMException comEx)
{
}
}
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
Other Resources
How to: Specify Whether to Display a Contact's Picture in Outlook (Outlook 2010 Auxiliary Reference)