Open a _PostItem in custom form.

  • Thread starter Thread starter Vladimir Chtchetkine
  • Start date Start date
V

Vladimir Chtchetkine

This is a big one for me. I want an item (doesn't really matter, _Mail or
_Post but preferably _Post) to be opened (_Inspector'ed) in a specific form
(I have a form file that I want to use). But no matter what I do, item keeps
opening in a default Outlook form.

I have an ugly work around: on item open (ItemEvents:Open) I create a new
item (using _Application::CreateItemFromTemplate(), copy all the properties
from the original item to the created one, create and open a new _Inspector
for that "templated" item, and set Calncel param to ItemEvents::Open to
true, so original item wouldn't open. Then, when inspector with "templated"
item is closing I copy all the changes to the original item and delete
"templated" one.

Ugly, huh?

Is there more elegant solution? I mean can I (from inside an add-in) open an
existing Outlook item in an arbitrary form (well, form, that supports item's
type)?



TIA,



Vladimir
 
An Outlook item always opens in the form specified in the item's
MessageClass property. Therefore, to change the form that an item displays
with, you must change that property value. Practically speaking, you will
also need to dereference the object for that item before you open it again.
 
Thanks, Sue!

I experimented a bit with what you've suggested (changing MessageClass) but
it seem to have no effect. The item keeps opening with the default form. I
guess I should be looking for the clue in your "you will also need to
dereference the object" but I have no clue what does this means :-) Can you
explain please? And another (side but close) question: how do I publish form
(programmaticaly) from an .oft file?

Regards,

Vladimir
 
Alas, I can tell you how to dereference an object in VB/VBA, but not in
other programming languages, which I suspect you're using. Maybe if you tell
us what you're using, someone familiar with that language can jump in and
provide that information.

To publish a form programmatically from an .oft file, use the
APplication.CreateItemFromTemplate method to create an item from that form,
get that item's FormDescription, and then use the
FormDescription.PublishForm method.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I'm in C++ domain :-) But understand VB (at least on syntactic level)
Thanks for the hint on publishing a form. Pretty straight forward, I
should've guessed myself :-)

Regards,

Vladimir
 
In VB, it's as simple as:

Set objItem = Nothing

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top