View Single Post
  #4  
Old March 2nd 09, 07:01 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default programmatically set up default form

OlFormRegistry.olFolderRegistry, not OlFormRegistry.olPersonalRegistry.

An error is to be expected if you use the Folder argument and supply the
Personal Forms Library as the first argument.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jason" wrote in message
...
Thanks Ken.

Me and another guy tried folder but could not make it work. Got runtime
ComInterop error on publish line:


formDescription.PublishForm(Outlook.OlFormRegistry .olPersonalRegistry,
calendarFolder);

the error message is "One or more parameters are incorrect."

Code:

private void PublishCustomForm()
{
Outlook.Application app = Globals.ThisAddIn.Application;
Outlook.NameSpace ns = app.GetNamespace("MAPI");
Outlook.MAPIFolder calendarFolder =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derCalendar);

object missing = System.Reflection.Missing.Value;

// create the item from TemplateFile

//Outlook.AppointmentItem item =
(Outlook.AppointmentItem)app.CreateItemFromTemplat ",
calendarFolder);
//Outlook.FormDescription formDescription = item.FormDescription;

object item = ", calendarFolder);
Type itemType = item.GetType();
Outlook.FormDescription formDescription =
(Outlook.FormDescription)itemType.InvokeMember("Fo rmDescription",
System.Reflection.BindingFlags.GetProperty, null, item, null);

// Apply some Parameters to the Formdescription
formDescription.Name = "xxx";

// Publish Form to Personal Froms Library
formDescription.PublishForm(Outlook.OlFormRegistry .olPersonalRegistry,
calendarFolder);
}


Ads