Add controls with out publishing in C#

L

lg

Hi,
Is it possible to add a custom form to an Appointment Item and contols
to that custom form in C# and make the form visible with out publishing the
form ? What I want to do (and dont know if is possible) is if a user has the
add-in installed and opens an Appointment Item, the Appointment Item will
display the custom form but if user sends the appointment (meeting request)
to other users, it sends the normal appointment item without the custom form.
 
S

Sue Mosher [MVP-Outlook]

I doubt that it would work. Adding controls programmatically embeds the form definition into the item, so it would probably travel with the meeting request. Either wait for Outlook 2007 and form regions or use the third-party component at http://www.add-in-express.com/outlook-extension/ to accomplish the same thing in earlier versions.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

An item of any type doesn't get a custom form added, it either uses a custom
form or uses the standard form for that Class of item.

It's never a good idea to add controls at runtime to a form, that one-offs
the item and causes various bad things. The best approach is to use an
already published custom form and set the MessageClass of the item to that
MessageClass to display your custom controls. After you display/harvest data
from the item you can then change the MessageClass back to its original
setting.
 
L

lg

Thanks for the help Ken and hi Sue, I am working with Outlook 2003, is there
any way of adding a custom form in the New_Inspector event and when the user
selects Send (arranging a meeting with other users), in the send event remove
the custom form and send the appointment item as normal without the custom
form and therefore not one-offing the form.
 
S

Sue Mosher [MVP-Outlook]

It might be possible in the AppointmentItem.Send event handler, but my experience is that anything involving custom forms and meeting requests is a little dicey.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
L

lg

I can remove the controls from the custom form in the send event but when it
comes to removing the custom form itself (the tab on the appointment item) in
the event it dosnt work. I have also tried hiding the custom form also using
the "HideFormPage" method and that dosnt seem to work either.

I saw on another thread where you suggected to hide the form before
publishing it and then show it when needed but I am afraid it did'nt work
here. Do you have any suggestions why ?
 
S

Sue Mosher [MVP-Outlook]

I saw on another thread where you suggected to hide the form before
publishing it and then show it when needed but I am afraid it did'nt work
here. Do you have any suggestions why ?

What in particular didn't work? Code snippet?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
L

lg

private void ThisApplication_Startup(object sender, System.EventArgs e)
{

...........

// Get the form Description and publish it. "appointmentItem" is an
object
// to the custom form returned from "CreateItemFromTemplate"
appointmentItem.GetInspector.HideFormPage ("TestPage");

formDescription = appointmentItem.FormDescription;
formDescription.Name = "Appointment";
formDescription.PublishForm(
Microsoft.Office.Interop.Outlook.OlFormRegistry.olFolderRegistry,
MAPIFolder);
}

public void New_Inspector(Outlook.Inspector Inspector)
{
..............
Inspector.ShowFormPage("TestPage");
}

(The checks to make sure that a appointment item is opened are omitted.)
When a new appointment item is opened the "TestPage" form is still not
visible but if you go into the design mode of the item the TestPage there.
 
S

Sue Mosher [MVP-Outlook]

You need to create the form to look the way you want it to -- including hiding any necessary pages -- before you save it as an .oft form template file.

Check for a typo in the page name string. Trailing spaces matter.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
L

lg

I see what one of the problems might be, I was create a generic
AppointmentItem object using the "CreateItem" method, adding the custom form
(the new tab) and the controls, then publishing the AppointItem object. It
sometimes work when I read in from the oft file but I think there is some
sort of caching issue with Outlook. I get some weird results though, when I
was the NewInspector event to show the custom form it sometimes work but if I
use the Open event it seem to work better, do you know why this is ?
 
S

Sue Mosher [MVP-Outlook]

NewInspector is an event that fires when the user displays an item. Whether it uses a custom form depends on the value of the MessageClass property, if it's a stored item, or what method was used to create the item if it's a new item. If you want to change the value of MessageClass, you must use the MailItem.Open event handler, change the MessageClass, save the item, get its MesssageClass, cancel the Open event, then open the item programmatically using GetItemFromID.

In other words, you can't change the form for an item on the fly without saving it and getting it as a completely new Inspector.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

Usually in the NewInspector event handler the only properties of
Inspector.CurrentItem that may be available are MessageClass and Class,
EntryID may also be available. You are best waiting for the first Activate
of the Inspector.

But, as Sue mentioned sending meeting requests and trying to fudge things is
a frustrating exercise.
 
K

Ken Slovak - [MVP - Outlook]

And trying to make certain changes in Item.Send usually will fail. You might
have to cancel the send, set a timer to fire after the send event terminates
and mark the item or a flag in your Inspector class handler and then do the
changes in the timer event handler, then send the item again.




NewInspector is an event that fires when the user displays an item. Whether
it uses a custom form depends on the value of the MessageClass property, if
it's a stored item, or what method was used to create the item if it's a new
item. If you want to change the value of MessageClass, you must use the
MailItem.Open event handler, change the MessageClass, save the item, get its
MesssageClass, cancel the Open event, then open the item programmatically
using GetItemFromID.

In other words, you can't change the form for an item on the fly without
saving it and getting it as a completely new Inspector.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top