g_olNamespace = m_olOutlookApp.Session
g_olNamespace.Logon(, , False, False)
g_objMAPISession = New MAPI.Session
g_objMAPISession.Logon(, , False, False)
Public Function SetFolderDftMsgPostClass(ByVal sFolderID As String, ByVal sStoreID As String) As Boolean
Dim objMAPIFolder As MAPI.Folder
Dim objMAPIFields As MAPI.Fields
Const PR_DEF_POST_DISPLAYNAME = &H36E6001E '定制form的显示名字
Const PR_DEF_POST_MSGCLASS = &H36E5001E '定制form的MessageClass名称
Try
objMAPIFolder = g_objMAPISession.GetFolder(sFolderID, sStoreID)
objMAPIFields = objMAPIFolder.Fields
Try
If objMAPIFields.Item(PR_DEF_POST_MSGCLASS).value = cVerseMessageClass Then
Exit Try
End If
Catch ex As Exception
With objMAPIFields
.Add(PR_DEF_POST_DISPLAYNAME, cVerseFormName)
.Add(PR_DEF_POST_MSGCLASS, cVerseMessageClass)
End With
objMAPIFolder.Update()
End Try
Catch ex As Exception
Finally
End Try
DisposeObject(objMAPIFields)
DisposeObject(objMAPIFolder)
End Function |