A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

programmatically set up default form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 1st 09, 09:26 PM posted to microsoft.public.outlook.program_addins
Jason
external usenet poster
 
Posts: 41
Default programmatically set up default form

For Outlook 2003, the solution in the MS article "How to globally change the
default forms in Outlook by using the Forms Administrator utility"
http://support.microsoft.com/kb/241235 only works if the custom form is
published to a folder; it does not work if the form is published into
Personal Form Library.


Question 1: What is the code to publish a form into calendar folder in
Outlook 2003?

The C# code here http://www.outlookcode.com/codedetail.aspx?id=1033 only
publishes the form to Personal Form Library. How to change it for calendar
folder?

I found the code sometime ago. It published the form into calendar folder
but at the same time created an appointment item in the folder. I lost that
code and cannot not retrieve it back.


Question 2: What is correct registry keys for Outlook 2003 when the form is
published into Personal Form Library? The keys below only works when the
form is published into calendar folder.


[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom Forms]

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom
Forms\Compose]
"IPM.Appointment"="xxxxx"

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom Forms\Read]
"IPM.Appointment"="xxxxx"


Ads
  #2  
Old March 2nd 09, 04:52 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default programmatically set up default form

When you supply the folder library to the Publish() method just use
OlFormRegistry.olFolderRegistry, then supply the optional Folder argument
with a Calendar folder object.

It only works when published to a folder or the Organizational Forms Library
(with Exchange).

--
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
...
For Outlook 2003, the solution in the MS article "How to globally change
the default forms in Outlook by using the Forms Administrator utility"
http://support.microsoft.com/kb/241235 only works if the custom form is
published to a folder; it does not work if the form is published into
Personal Form Library.


Question 1: What is the code to publish a form into calendar folder in
Outlook 2003?

The C# code here http://www.outlookcode.com/codedetail.aspx?id=1033 only
publishes the form to Personal Form Library. How to change it for calendar
folder?

I found the code sometime ago. It published the form into calendar folder
but at the same time created an appointment item in the folder. I lost
that code and cannot not retrieve it back.


Question 2: What is correct registry keys for Outlook 2003 when the form
is published into Personal Form Library? The keys below only works when
the form is published into calendar folder.


[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom Forms]

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom
Forms\Compose]
"IPM.Appointment"="xxxxx"

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom
Forms\Read]
"IPM.Appointment"="xxxxx"



  #3  
Old March 2nd 09, 06:48 PM posted to microsoft.public.outlook.program_addins
Jason
external usenet poster
 
Posts: 41
Default programmatically set up default form

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);
}





"Ken Slovak - [MVP - Outlook]" wrote in message
...
When you supply the folder library to the Publish() method just use
OlFormRegistry.olFolderRegistry, then supply the optional Folder argument
with a Calendar folder object.

It only works when published to a folder or the Organizational Forms
Library (with Exchange).

--
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
...
For Outlook 2003, the solution in the MS article "How to globally change
the default forms in Outlook by using the Forms Administrator utility"
http://support.microsoft.com/kb/241235 only works if the custom form is
published to a folder; it does not work if the form is published into
Personal Form Library.


Question 1: What is the code to publish a form into calendar folder in
Outlook 2003?

The C# code here http://www.outlookcode.com/codedetail.aspx?id=1033 only
publishes the form to Personal Form Library. How to change it for
calendar folder?

I found the code sometime ago. It published the form into calendar folder
but at the same time created an appointment item in the folder. I lost
that code and cannot not retrieve it back.


Question 2: What is correct registry keys for Outlook 2003 when the form
is published into Personal Form Library? The keys below only works when
the form is published into calendar folder.


[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom Forms]

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom
Forms\Compose]
"IPM.Appointment"="xxxxx"

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Custom
Forms\Read]
"IPM.Appointment"="xxxxx"





  #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);
}


  #5  
Old March 3rd 09, 07:18 AM posted to microsoft.public.outlook.program_addins
Jason
external usenet poster
 
Posts: 41
Default programmatically set up default form

Great. It works. The form was published into calendar folder with no side
effect. However, the custom form did not become default form even the
"custom form" registry keys were there. It does show up in the "when posting
to this folder, use" dropdownlist.

I was wrong. The "custom form" registry keys created by admin tool did not
work, no matter the custom form wsa published manually or programmatically.
Looks like I have to give up and ask user to do it manually.


"Ken Slovak - [MVP - Outlook]" wrote in message
...
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);
}




  #6  
Old March 3rd 09, 02:49 PM posted to microsoft.public.outlook.program_addins
Jason
external usenet poster
 
Posts: 41
Default programmatically set up default form

"custom form" registry keys work. It does not matter where the form is
published to, either calanedar folder or personal form library. What
confused me was that the "use" dropdownlist does not change. I guess the
default selection here does not matter because registry key setting
overrides it.

Publish form works. I'd move it to the first run of add-in.

Thank you very much Ken.


"Jason" wrote in message
...
Great. It works. The form was published into calendar folder with no side
effect. However, the custom form did not become default form even the
"custom form" registry keys were there. It does show up in the "when
posting to this folder, use" dropdownlist.

I was wrong. The "custom form" registry keys created by admin tool did not
work, no matter the custom form wsa published manually or
programmatically. Looks like I have to give up and ask user to do it
manually.


"Ken Slovak - [MVP - Outlook]" wrote in message
...
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);
}






  #7  
Old March 3rd 09, 02:59 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default programmatically set up default form

You'd need to use a different API (lower level) or Outlook 2007 to set that
up correctly.

The properties you need to set would be:

PR_DEF_POST_DISPLAYNAME (0x36E6001E) a PT_STRING8 property to the display
name of the custom form (for example "MyForm").

PR_DEF_POST_MSGCLASS (0x36E5001E) also a PT_STRING8 property to the custom
MessageClass of your form ("IPM.Appointment.MyForm").

Aside from Outlook 2007's PropertyAccessor, you can work with those
properties using CDO 1.21 (no managed code support), Extended MAPI (C++ or
Delphi only, no managed code support) or a MAPI COM wrapper such as
Redemption (www.dimastr.com/redemption).

Setting those properties is the equivalent of setting what you see in the
Properties dialog for the folder in the UI for the "When posting to this
folder, use: " setting.

Setting the following properties is the equivalent of setting the "Forms
associated with the this folder:" property in the Forms tab of the folder
Properties dialog:

PR_ENTERPRISE_FORMS_CN (0x36E7101E) a PT_MV_STRING8 (multivalued string,
which is a string array) to the same custom MessageClass as
PR_DEF_POST_MSGCLASS.

PR_ENTERPRISE_FORMS_DN (0x36E8101E) also a PT_MV_STRING8 (multivalued
string, which is a string array) to the same display name used for
PR_DEF_POST_DISPLAYNAME.

--
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
...
Great. It works. The form was published into calendar folder with no side
effect. However, the custom form did not become default form even the
"custom form" registry keys were there. It does show up in the "when
posting to this folder, use" dropdownlist.

I was wrong. The "custom form" registry keys created by admin tool did not
work, no matter the custom form wsa published manually or
programmatically. Looks like I have to give up and ask user to do it
manually.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically creating emails with default stationery Ken Warthen Outlook and VBA 2 October 28th 08 03:29 PM
how to programmatically change default account muybn Outlook and VBA 3 October 16th 07 05:54 AM
Programmatically manipulate form regions robert Outlook - Using Forms 2 May 23rd 07 08:14 PM
programmatically opening a form mikelee101 Outlook - Using Forms 7 March 16th 07 09:43 PM
Help forwarding form programmatically Trent Outlook - Using Forms 3 October 18th 06 06:36 PM


All times are GMT +1. The time now is 04:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.