Custom Form ERROR

B

back2grid

Hi,
I have what seems to be a strange problem. Firstly i created a add-in in
vs.net that adds new tasks for a user from a project management app. In order
to view custom data from the external app i've created a custom form. This
form contains basically a ActiveX control (written in .NET C#). When the
item(s) are
added, the message class is set to this custom form. The problem i'm seeing
is
that immediately after my add-in loads the tasks, and i click open a task,
the default form shows up instead of custom form. Now If i close my outlook
app (not just the item) and start it up again and then open the same task
item, i get the task in my custom form.
To work around i create a outlook template file of my custom form. i then
add items by using the createitemfromtemplate function. After adding the
ActiveAllowOneOffForms with DWORD set to 1. i get everything working smoothly.

Why is outlook not loading the custom form for the first time. i would like
to avoid the registry entry.

Anybody seen this issue before.

thanks
 
S

Sue Mosher [MVP-Outlook]

Maybe you could show a code snippet to illustrate how you're creating the tasks. If you want them to use a custom form, you should be using a published form and creating the items with Add method on the target folder's Items collection.
 
B

back2grid

Sue,
thanks for the reply. Here it goes..
Outlook.Application app = new Application();
TaskItem item = null;
item = (TaskItem)app.CreateItem(OlItemType.olTaskItem);
item.subject = ...
item.MessageClass = "IPM.Task.MyCustomForm";
item.Save();

this code adds the item correctly but when i open the task for view my
custom form it just opens the default form. If i close and open outlook
applicaiton, the tasks now open in the intended "MyCustomForm".

Right now i've saved the form as a Outlook template and use the following
code.
Outlook.ApplicationClass appClass = new ApplicaitonClass():
Outlook.NameSpace ns = appClass.GetNameSpace("MAPI);
Outlook.MAPIFolder oTaskItems =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);

item =
(TaskItem)app.CreateItemFromTemplate("C:\myformTemplate.oft",oTaskItems);
item.subject = ...
item.MessageClass = "IPM.Task.MyCustomForm";
item.Save();

Using this code and adding the AllowActivexOneOffForms registry entry seems
to be working correctly. But i wanted to have the code piece #1 to be working
correctly. The forms are obviously published.

hope this helps

thanks
 
S

Sue Mosher [MVP-Outlook]

As I said, to create a new instance of a custom form programmatically, you need to use the Add method on the target folder's Items collection. Pass the message class of the form as the argument:
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

back2grid

It worked!!!
thanks sue. My other post regarding Userproperties being lost. that problem
seems also resolved. i will further test and let me know. One other strange
thing i observe is that sometimes, when i close outlook and try to open
immediately it says "The Operation failed". After may be 3-4 seconds, outlook
opens nicely and works fine. I thinks outlook takes time to unload the
activex controls i guess.
Any idea?

thanks again Sue
 
S

Sue Mosher [MVP-Outlook]

Outlook has to unload all its mail account services, close PST files, etc. Wait a little longer.

--
Sue Mosher, Outlook MVP
Author of
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