How to Programmatically Publish a FormID: Q186437
|
This article provides code samples that show how the Outlook object model can be used to publish a form. The samples cover using Microsoft Visual Basic and Microsoft Visual Basic Scripting Edition (VBScript) to perform this task.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
Option Explicit
Dim olNS
Dim MyFolder
Dim MyItem
Dim MyForm
Sub CommandButton1_Click()
Set olNS = Item.Application.GetNamespace("MAPI")
Set MyFolder = olNS.GetDefaultFolder(6) '6=olFolderInbox
Set MyItem = Application.CreateItem(0) '0=MailItem
Set MyForm = MyItem.FormDescription
MyForm.Name = "MyInboxForm"
MyForm.PublishForm 3, MyFolder '3=olFolderRegistry
Item.Close 1 '1=olDiscard
End Sub
Option Explicit
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Outlook.MailItem
Dim myForm As Outlook.FormDescription
Private Sub Command1_Click()
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
olNS.Logon , , True, True
Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
Set olItem = olApp.CreateItem(olMailItem)
Set myForm = olItem.FormDescription
myForm.Name = "MyInboxForm"
myForm.PublishForm olFolderRegistry, olFolder
Unload Me
End Sub
For information concerning a problem with the PublishForm method, please see the following article in the Microsoft Knowledge Base:
Q222526 OL98: Outlook Doesn't Exit After Using PublishForm MethodFor more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base:
Q180826 OL98: Resources for Custom Forms and ProgrammingFor more information about how to reference other items and folders, please see the following articles in the Microsoft Knowledge Base:
Q182349 OL98: Questions About Custom Forms and Outlook Solutions
Q182614 OL98: Programming Examples for Referencing Items and FoldersSearch the Microsoft Developer Network (MSDN) Library and the Microsoft Outlook Visual Basic for Applications help file (Vbaoutl.hlp) for the following keywords: Outlook FormDescription
Additional query words: OutSol OutSol98
Keywords : kbdta kbdtacode OffVBS
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: August 2, 1999