D
ddsfdfs
I have a Com-addin that is using a custom contact form which is published as
the default for a contact folder. The com-addin is designed so that when
users to drag in their own contacts into this form and will update it to use
the new custom contact form by changing its MessageClass. This works kind
of.
When I drag the contact to the folder the MessageClass changes to reflect
using the new contact form (IPM.Contact.SharedContacts) however when I open
the form it is still using the default contact form. If I exit Outlook and
reopen the same contact it now correctly uses the custom form.
Here is the code that I use to change the MessageClass.
Private Sub m_olExplorer_BeforeFolderSwitch(ByVal NewFolder As Object,
ByRef Cancel As Boolean) Handles m_olExplorer.BeforeFolderSwitch
Dim oFolder As Outlook.MAPIFolder
On Error Resume Next
oFolder = NewFolder
If oFolder.Name = "Upload Contacts" Then
Dim NewMC As String = "IPM.Contact.SharedContacts"
Dim i As Integer
Dim AllItems As Outlook.Items = oFolder.Items
Dim NumItems As Integer = oFolder.Items.Count
Dim CurItem As Outlook.ContactItem
' Loop through all of the items in the folder
For i = 1 To NumItems
CurItem = AllItems.Item(i)
' Test to see if the Message Class needs to be changed
If CurItem.MessageClass <> NewMC Then
' Change the Message Class
CurItem.MessageClass = NewMC
' Save the changed item
CurItem.Save()
End If
Next
End If
End Sub
the default for a contact folder. The com-addin is designed so that when
users to drag in their own contacts into this form and will update it to use
the new custom contact form by changing its MessageClass. This works kind
of.
When I drag the contact to the folder the MessageClass changes to reflect
using the new contact form (IPM.Contact.SharedContacts) however when I open
the form it is still using the default contact form. If I exit Outlook and
reopen the same contact it now correctly uses the custom form.
Here is the code that I use to change the MessageClass.
Private Sub m_olExplorer_BeforeFolderSwitch(ByVal NewFolder As Object,
ByRef Cancel As Boolean) Handles m_olExplorer.BeforeFolderSwitch
Dim oFolder As Outlook.MAPIFolder
On Error Resume Next
oFolder = NewFolder
If oFolder.Name = "Upload Contacts" Then
Dim NewMC As String = "IPM.Contact.SharedContacts"
Dim i As Integer
Dim AllItems As Outlook.Items = oFolder.Items
Dim NumItems As Integer = oFolder.Items.Count
Dim CurItem As Outlook.ContactItem
' Loop through all of the items in the folder
For i = 1 To NumItems
CurItem = AllItems.Item(i)
' Test to see if the Message Class needs to be changed
If CurItem.MessageClass <> NewMC Then
' Change the Message Class
CurItem.MessageClass = NewMC
' Save the changed item
CurItem.Save()
End If
Next
End If
End Sub