More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

share code 23-Mar-2017 00:55

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

Code level: intermediate    Code area: Outlook Form Design Printer Friendly Version
Title: List the custom forms in a folder
Description: This VBA sample displays a message box with the list of custom forms published to a folder. Note that a reference to CDO 1.21 is required. For an Outlook 2007 approach using the Table object instead of CDO, see Listing 21.1 in my Outlook 2007 book.
Date: 06-Sep-2007  07:48
Code level: intermediate
Code area: Outlook Form Design
Posted by: Sue Mosher
This message is displayed as VB.NET
 Sub ListForms(fld As Outlook.MAPIFolder)
    Dim strList As String
    ' requires reference to Collaboration Data Objects library
    '   (CDO 1.21)
    Dim cdoSession As MAPI.Session
    Dim cdoFolder As MAPI.folder
    Dim cdoFilter As MAPI.MessageFilter
    Dim cdoMessages As MAPI.Messages
    Dim cdoMessage As MAPI.Message
    Const CdoPR_Form_Name = &H6800001E
    On Error Resume Next
    Set cdoSession = CreateObject("MAPI.Session")
    cdoSession.Logon "", "", False, False
    Set cdoFolder = cdoSession.GetFolder(fld.EntryID, fld.storeID)
    Set cdoMessages = cdoFolder.HiddenMessages
    For Each cdoMessage In cdoMessages
        If cdoMessage.Type = _
          "IPM.Microsoft.FolderDesign.FormsDescription" Then
            strList = strList & vbCrLf & _
        End If
    If Len(strList) > 0 Then
        strList = Mid(strList, 2)
        strList = "No forms found in folder"
    End If
    MsgBox strList, vbInformation, "Forms in " & fld.Name & " folder"
    Set cdoSession = Nothing
    Set cdoFolder = Nothing
    Set cdoMessage = Nothing
    Set cdoMessages = Nothing
End Sub
All 0comments