V
Valentin
Hi all!
I have a public folder that contains contacts. I was asked to change
the contacts from the default form to a slightly different form, more
specifically, one that wouldn't show the Certificates tab.
I modified the default Contact form and published it as
Custom_Contact_View and then I ran a VBA procedure that I found in
section 24.1.3 in the book "Microsoft Outlook Programming"(written by
Sue Mosher). The procedure ran without a hitch, but when I started
opening the contacts, I discovered that some of them had not been
converted. I checked and all items in the public folder are of type
"Contact", so, what could be the problem?
This is the code that I used:
'=============================================================
' UpdateMessageClass
' Listing 24.3
'-------------------------------------------------------------
' Purpose : Apply a new form to existing items
' Notes : Assumes g_CDOSession MAPI.Session global variable
' uses reference to Microsoft CDO 1.21 Library (cdo.dll)
'=============================================================
Sub UpdateMessageClass()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objCDOFolder As MAPI.Folder
Dim colCDOMessages As MAPI.Messages
Dim objCDOMessage As MAPI.Message
Dim objFilter As MAPI.MessageFilter
Dim strClass As String
Dim strFolderClass As String
Dim strMsg As String
Dim strTitle As String
Dim iCntr As Integer
On Error Resume Next
iCntr = 0
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
strMsg = "Change all items in folder to what class?"
strTitle = "UpdateMessageClass"
strClass = InputBox(strMsg, strTitle)
strFolderClass = objFolder.DefaultMessageClass
'MsgBox strFolderClass
If InStr(1, strClass, strFolderClass, _
vbTextCompare) Then
Call DoCDOLogon
Set objCDOFolder = _
g_CDOSession.GetFolder(objFolder.EntryID, _
objFolder.StoreID)
Set colCDOMessages = objCDOFolder.Messages
Set objFilter = colCDOMessages.Filter
objFilter.Type = strFolderClass
For Each objCDOMessage In colCDOMessages
objCDOMessage.Type = strClass
objCDOMessage.Update
Next
Call DoCDOLogoff
strMsg = "Updated items in " & objFolder.Name & " Folder"
MsgBox strMsg, , strTitle
Else
strMsg = "The class you specified is not the normal " & _
"type for this folder. " & _
"No items will be updated."
MsgBox strMsg, , strTitle
End If
End If
Set objFolder = Nothing
Set objCDOFolder = Nothing
Set objCDOMessage = Nothing
Set colCDOMessages = Nothing
Set objFilter = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
I have a public folder that contains contacts. I was asked to change
the contacts from the default form to a slightly different form, more
specifically, one that wouldn't show the Certificates tab.
I modified the default Contact form and published it as
Custom_Contact_View and then I ran a VBA procedure that I found in
section 24.1.3 in the book "Microsoft Outlook Programming"(written by
Sue Mosher). The procedure ran without a hitch, but when I started
opening the contacts, I discovered that some of them had not been
converted. I checked and all items in the public folder are of type
"Contact", so, what could be the problem?
This is the code that I used:
'=============================================================
' UpdateMessageClass
' Listing 24.3
'-------------------------------------------------------------
' Purpose : Apply a new form to existing items
' Notes : Assumes g_CDOSession MAPI.Session global variable
' uses reference to Microsoft CDO 1.21 Library (cdo.dll)
'=============================================================
Sub UpdateMessageClass()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objCDOFolder As MAPI.Folder
Dim colCDOMessages As MAPI.Messages
Dim objCDOMessage As MAPI.Message
Dim objFilter As MAPI.MessageFilter
Dim strClass As String
Dim strFolderClass As String
Dim strMsg As String
Dim strTitle As String
Dim iCntr As Integer
On Error Resume Next
iCntr = 0
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
strMsg = "Change all items in folder to what class?"
strTitle = "UpdateMessageClass"
strClass = InputBox(strMsg, strTitle)
strFolderClass = objFolder.DefaultMessageClass
'MsgBox strFolderClass
If InStr(1, strClass, strFolderClass, _
vbTextCompare) Then
Call DoCDOLogon
Set objCDOFolder = _
g_CDOSession.GetFolder(objFolder.EntryID, _
objFolder.StoreID)
Set colCDOMessages = objCDOFolder.Messages
Set objFilter = colCDOMessages.Filter
objFilter.Type = strFolderClass
For Each objCDOMessage In colCDOMessages
objCDOMessage.Type = strClass
objCDOMessage.Update
Next
Call DoCDOLogoff
strMsg = "Updated items in " & objFolder.Name & " Folder"
MsgBox strMsg, , strTitle
Else
strMsg = "The class you specified is not the normal " & _
"type for this folder. " & _
"No items will be updated."
MsgBox strMsg, , strTitle
End If
End If
Set objFolder = Nothing
Set objCDOFolder = Nothing
Set objCDOMessage = Nothing
Set colCDOMessages = Nothing
Set objFilter = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub