Now you see me, now you don't

My colleague Stephen Griffin recently blogged about how to show or hide the Sender Contact Photo feature in Outlook.  Since he only supplied the C++ version the product team asked me to supply the .NET version.  [Edit: 2/10/2014:  It has come to my attention that the code below will only work for Outlook 2010.  Support for this was removed in Outlook 2013.]

Visual Basic

 Public Sub SetSenderContactPhoto(ByVal Inspector As Object, ByVal ShowSenderContactPhoto As Boolean)
  Dim typeInspector As Type = Inspector.GetType()
  Dim dispidShowSenderPhotoMemberName As String = String.Format("[DispID={0}]", _ 
  Dim args() As Object = {ShowSenderContactPhoto}
    typeInspector.InvokeMember(dispidShowSenderPhotoMemberName, _ 
        System.Reflection.BindingFlags.InvokeMethod, _
        Nothing, _
        Inspector, _
  Catch comEx As System.Runtime.InteropServices.COMException

  End Try
End Sub



 void SetSenderContactPhoto(object Inspector, bool ShowSenderContactPhoto)
  Type typeInspector = Inspector.GetType();
  string dispidShowSenderPhotoMemberName = String.Format("[DispID={0}]", 0xF0D0);
  object[] args = {ShowSenderContactPhoto};

  catch(System.Runtime.InteropServices.COMException comEx)