none
Contact Custom Form Icon does not display in Contact List View RRS feed

  • Question

  • I have created a custom contact form and have assigned unique icons (both large and small) to the form.  They work correctly for contacts created using the custom form.  However, when I convert existing contacts (originally created using the default contact form) by updating the messageclass for the contact, it continues to display the default form icon in the list view.
    Wednesday, July 18, 2012 4:14 PM

Answers

  • I did some more digging regarding the PR_ICON_INDEX field and discovered how to update this field.  My code is below just in case anyone else stumbles across this issue.  I wrote the code below to allow the user to toggle between outlook forms.  Seems like a wierd need, but I have this in place just in case the user (my husband), selects the wrong form when entering the (personal vs professional) contact.  This allows an easy way to convert existing contacts on demand as well.  I assigned this macro to a button on the ribbon. 

    Dmitry, if you see anything wrong with my approach, can you please let me know.  I'm not sure why Microsoft does not include the need to update the PR_ICON_INDEX in their help screens, but, I cannot begin to thank you enough for getting me on the right path!

    Sub ChangeContactFormList()
    Dim myApp       As Outlook.Application
    Dim myExplorer  As Outlook.Explorer
    Dim myItem      As Outlook.ContactItem
    Dim myPA        As Outlook.PropertyAccessor
    Dim txtIconProp As String
    Dim errProp     As String
    Dim newForm     As String
    Dim itmCount    As Long
    Dim txtResults  As String

        txtResults = ""
        Set myApp = Application
        Set myExplorer = myApp.ActiveExplorer
       
        For itmCount = 1 To myExplorer.Selection.Count
            If myExplorer.Selection.Item(itmCount).Class <> olContact Then GoTo NextItem
            Set myItem = myExplorer.Selection.Item(itmCount)
            Set myPA = myItem.PropertyAccessor
            txtIconProp = myPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10800003")
            If myItem.MessageClass = "IPM.Contact" Then
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses the Standard Contact Form, action will convert contact to PPC Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact.PPC"
                newForm = "PPC Contact Form"
            ElseIf myItem.MessageClass = "IPM.Contact.PPC" Then
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses the PPC Contact Form, action will convert contact to Standard Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact"
                newForm = "Standard Contact Form"
            Else
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses and Unidentified Contact Form, action will convert contact to Standard Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact"
                newForm = "Standard Contact Form"
            End If
           
            If txtIconProp <> -1 Then
                myPA.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x10800003", -1
            End If
           
            myItem.Save
            txtresult = txtresult & Chr$(13) & Chr$(10) & _
                        "Contact: " & myItem.FullNameAndCompany & " converted to form " & newForm
    CloseItemAndNext:
        Set myItem = Nothing
       
    NextItem:
        Next itmCount
       
    ExitSub:
        Set myExplorer = Nothing
        Set myApp = Nothing
       
        If txtResults <> "" Then MsgBox txtResults
       
    End Sub

    • Marked as answer by pmay25 Wednesday, July 18, 2012 6:38 PM
    Wednesday, July 18, 2012 6:37 PM

All replies

  • Have you verified with MFCMAPI or OutlookSpy that the message class is correctly set?

    Is PR_ICON_INDEX property set on these contacts?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Wednesday, July 18, 2012 5:12 PM
  • Thank you so much for your quick reply to my issue.  I am not familiar with OutlookSpy, however, I have attempted to get the answers to your questions. 

    A little background.  Probably should mention that I am using Outlook 2010.  In trying to narrow down what the problem might be, I determined the following:

    1. If the contact is created using the default contact form, then when I programatically change the messageclass to that of the custom form, the icon does not change to reflect the custom form (everything else works as expected and the custom form is displayed when the contact is opened).

    2. If the contact is created using the custom form, then I can programatically change the messageclass back and forth between the default and custom form and the icon responds accordingly.

    Now, we are up to your response.  I installed OutlookSpy and verified the messageclass for both items and all looks in order for that field.  However, the second field you mention, PR_ICON_INDEX, is a different story.  Here is what I see:

    Contact created with default form: PR_ICON_INDEX = 512

    Contact created with custom form: PR_ICON_INDEX = -1

    Does this give you some insight as to what the problem is?  In all my days of research, this is the first I have heard of the PR_ICON_INDEX field.  If this is my problem, can you please share with me the steps to correct?

    Thank you so much for your help.  By the way, you have already help me more than you can imagine.  I have benefited greatly from the solutions you have provided for others.  I was thrilled to see that you responded to my issue!

    Patrece


    • Edited by pmay25 Wednesday, July 18, 2012 5:52 PM
    Wednesday, July 18, 2012 5:51 PM
  • I did some more digging regarding the PR_ICON_INDEX field and discovered how to update this field.  My code is below just in case anyone else stumbles across this issue.  I wrote the code below to allow the user to toggle between outlook forms.  Seems like a wierd need, but I have this in place just in case the user (my husband), selects the wrong form when entering the (personal vs professional) contact.  This allows an easy way to convert existing contacts on demand as well.  I assigned this macro to a button on the ribbon. 

    Dmitry, if you see anything wrong with my approach, can you please let me know.  I'm not sure why Microsoft does not include the need to update the PR_ICON_INDEX in their help screens, but, I cannot begin to thank you enough for getting me on the right path!

    Sub ChangeContactFormList()
    Dim myApp       As Outlook.Application
    Dim myExplorer  As Outlook.Explorer
    Dim myItem      As Outlook.ContactItem
    Dim myPA        As Outlook.PropertyAccessor
    Dim txtIconProp As String
    Dim errProp     As String
    Dim newForm     As String
    Dim itmCount    As Long
    Dim txtResults  As String

        txtResults = ""
        Set myApp = Application
        Set myExplorer = myApp.ActiveExplorer
       
        For itmCount = 1 To myExplorer.Selection.Count
            If myExplorer.Selection.Item(itmCount).Class <> olContact Then GoTo NextItem
            Set myItem = myExplorer.Selection.Item(itmCount)
            Set myPA = myItem.PropertyAccessor
            txtIconProp = myPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10800003")
            If myItem.MessageClass = "IPM.Contact" Then
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses the Standard Contact Form, action will convert contact to PPC Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact.PPC"
                newForm = "PPC Contact Form"
            ElseIf myItem.MessageClass = "IPM.Contact.PPC" Then
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses the PPC Contact Form, action will convert contact to Standard Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact"
                newForm = "Standard Contact Form"
            Else
                If MsgBox("Contact: " & myItem.FullNameAndCompany & " currently uses and Unidentified Contact Form, action will convert contact to Standard Contact Form.  Do you want to continue?", vbOKCancel) = vbCancel Then GoTo CloseItemAndNext
                myItem.MessageClass = "IPM.Contact"
                newForm = "Standard Contact Form"
            End If
           
            If txtIconProp <> -1 Then
                myPA.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x10800003", -1
            End If
           
            myItem.Save
            txtresult = txtresult & Chr$(13) & Chr$(10) & _
                        "Contact: " & myItem.FullNameAndCompany & " converted to form " & newForm
    CloseItemAndNext:
        Set myItem = Nothing
       
    NextItem:
        Next itmCount
       
    ExitSub:
        Set myExplorer = Nothing
        Set myApp = Nothing
       
        If txtResults <> "" Then MsgBox txtResults
       
    End Sub

    • Marked as answer by pmay25 Wednesday, July 18, 2012 6:38 PM
    Wednesday, July 18, 2012 6:37 PM