Please help on how to work with two custom forms

U

Unknown

We've a custom form published with both user definied
fields and VBScript on the form. All emails using this
custom form are archived on the Exchange Server. Since we
may make changes later on the custom form, adding and
renaming user defined fields, modifying the script, I'm
writing a utility app trying to remap all the user
definied fields between the two custom forms with
different message classes.

What I'm doing is to make a copy off each email and change
the message class from custom form 1 to custom form 2.
Then remove all user defined fields from form 1 and add
those for form 2 as well as set the values. It works fine
with the user defined fields and I can read the values
from custom form one and set it on custom form 2. But the
vbscript is missing from this object copying and saving.
If I do not create a copy off each original email, I do
not know if it is possible to rebuild the new mail object
from scratch, considering all different types of
attachments on the original emails.

What are the options for this? TIA
 
S

Sue Mosher [MVP-Outlook]

You should build Custom Form 2 to contain all the custom fields from Custom Form 1 and all the custom fields for Form 2. These should be visible in the form design in the User-Defined Fields in This Item, not just "... in This Folder."

After you change the MessageClass value, save the item, and dereference it. Then get it again using its EntryID and Namespace.GetItemFromID. It should be available in Form 2, with all the fields you need already present and waiting to accept values.
 
U

Unknown

Sue,

I checked some of the previous postings. My concern with
this is how to rebuild a mail item with different
attachments, especially those with embedded files. Some
of the postings are saying only certain types of
attachments can be handled but not all. Is Redemption an
alternative for this solution? Thanks!
-----Original Message-----
You should build Custom Form 2 to contain all the custom
fields from Custom Form 1 and all the custom fields for
Form 2. These should be visible in the form design in the
User-Defined Fields in This Item, not just "... in This
Folder."
After you change the MessageClass value, save the item,
and dereference it. Then get it again using its EntryID
and Namespace.GetItemFromID. It should be available in
Form 2, with all the fields you need already present and
waiting to accept values.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

Who said anything about rebuilding a mail item? All we've been talking about is changing properties on existing items.

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

Unknown

Sorry, my mistake.

I tested with your recommendation. All the user defined
fields are working fine. I also have VBScript on the
form to handle Send event. I made some changes on form 2
so form 1 and form 2 also have different VBScript
functions. Once I save, dereference and reference after
changing the message class, all the code is gone. The
email using the new message class does not have any code
on it. Did I miss anything? Thanks!

-----Original Message-----
Who said anything about rebuilding a mail item? All
we've been talking about is changing properties on
existing items.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

Did you publish the form with the "send form definition with item" box checked or cleared? How are you looking to see if there's code?

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

Unknown

I published the form with the box cleared. What I did
was to display the mail after saving, dereferencing and
referencing. Once the mail is open, I select design this
form to check the code.

Also form1 is currently published in the organizational
forms library. Form2 is published in my personal. Not
sure if this makes difference though. Thanks.
-----Original Message-----
Did you publish the form with the "send form definition
with item" box checked or cleared? How are you looking to
see if there's code?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

Where the form is published should not make a difference, for now, if all the items are in your own mailbox.

A better check would be to see whether any code actually runs. <g> For testing, I'd try opening another item first before opening the one just changed.

Can you show a short code snippet that shows how you're changing and saving the item? Does the changed item correctly show the right form information in Help | About This Form?

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

Unknown

Sue,

The code on form 2 does not run since I added a message
box in the open event. I'll post the code I have and also
check under help.

BTW, do I need to open the original email using form 1 and
then open the email saved with form 2? Thanks.


-----Original Message-----
Where the form is published should not make a difference,
for now, if all the items are in your own mailbox.
A better check would be to see whether any code actually
runs. said:
Can you show a short code snippet that shows how you're
changing and saving the item? Does the changed item
correctly show the right form information in Help | About
This Form?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

Please start with just a minimal code snippet. My eyeballs glaze over all too fast.

You shouldn't need to open either item if you're just updating the copy to use a new form.

What, BTW, did you see when you looked at the All Fields tab for your fields while designing Form 2?

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

Unknown

' mailItem is using form 1
' mailItemCopy is using form 2

....
Set mailItemCopy = mailItem.Copy

Set mailItemCopy.MessageClass = newMessageClass

mailItemCopy.Save
mailItemID = mailItemCopy.EntryID
storeID = mailItemCopy.Parent.StoreID

Set mailItemCopy = Nothing
' I do not have the code with me
' and the method's name, GetItemByID may be wrong
Set mailItemCopy = oNsp.GetItemByID(mailItemID, storeID)

' Code to read the values from the user defined fields
' on mailItem and set the associated fields on mailItemCopy

' I also display mailItemCopy here
' and able to use Redemption to
' verify the values are set correctly on mailItemCopy

Under All fields tab, I have all fields from both form 1
and form 2 listed. I'm actually confused here since the
drop-down list is showing options for Inbox, Item, etc.

I'll provide more code and info once I get on the PC at
work remotely. Thanks!


-----Original Message-----
Please start with just a minimal code snippet. My
eyeballs glaze over all too fast.
You shouldn't need to open either item if you're just
updating the copy to use a new form.
What, BTW, did you see when you looked at the All Fields
tab for your fields while designing Form 2?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

This line is trying to set a property with object methods and may very well be part of the problem:

Set mailItemCopy.MessageClass = newMessageClass

It should just be

mailItemCopy.MessageClass = newMessageClass

You also might try saving the message both before and after you change the class.

You weren't specific about the All Fields tab. The list that's critical to your form design are the fields under "User-defined fields in this item."

Did you check Help | About This Form yet?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
U

Unknown

Sue,

That was a typo. Sorry. Here's the code I have:

' Make a copy
Set mapiItemCopy = mapiItem.Copy

' Change the message class
mapiItemCopy.MessageClass = newMessageClass
' Save the copy
mapiItemCopy.Save

' reference the mail item
mailItemID = mapiItemCopy.EntryID
mailStoreID = mapiItemCopy.Parent.storeID
Set mapiItemCopy = Nothing
Set mapiItemCopy = g_oNsp.GetItemFromID(mailItemID,
mailStoreID)


I checked the under All Fields tab. My form 1 has all
user defined fields listed under User-defined fields in
this item but form 2 has everything listed under User-
defined fields in Inbox.

I deleted all UDF fields from form 2 and tried to add
them back under User-defined fields in this item. But
for some reason, they are automatically added to User-
defined fields in Inbox.

I also checked under Help | About This Form for both
forms. Neither one has anything there. Thanks.
-----Original Message-----
This line is trying to set a property with object
methods and may very well be part of the problem:
Set mailItemCopy.MessageClass = newMessageClass

It should just be

mailItemCopy.MessageClass = newMessageClass

You also might try saving the message both before and after you change the class.

You weren't specific about the All Fields tab. The list
that's critical to your form design are the fields
under "User-defined fields in this item."
Did you check Help | About This Form yet?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
U

Unknown

Another thing just wanted to mention...

When I apply

Set mailItemCopy = mailItem.Copy
or
Set mailItemCopy = mailItem.Forward

mailItemCopy is displayed in Edit Compose Page not Edit
Read Page. I really want mailItemCopy to be in the Edit
Read Page. Thanks.


-----Original Message-----
This line is trying to set a property with object
methods and may very well be part of the problem:
Set mailItemCopy.MessageClass = newMessageClass

It should just be

mailItemCopy.MessageClass = newMessageClass

You also might try saving the message both before and after you change the class.

You weren't specific about the All Fields tab. The list
that's critical to your form design are the fields
under "User-defined fields in this item."
Did you check Help | About This Form yet?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 
S

Sue Mosher [MVP-Outlook]

That sounds like the problem. You need to add the fields explicitly to the form so that they will already be in each item when you convert it. If you've already added the fields to the folder, then the easiest thing to do is drag each field to a custom page on the form. You can then delete those controls and hide the page again. See http://www.outlookcode.com/d/fields.htm for a lengthier explanation.

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

Sue Mosher [MVP-Outlook]

Forwarding an item always creates a new unsent item. Therefore, it will always appear with the compose layout.
 
U

Unknown

Sue,

That solved my problem. Thanks so much!
-----Original Message-----
That sounds like the problem. You need to add the fields
explicitly to the form so that they will already be in
each item when you convert it. If you've already added
the fields to the folder, then the easiest thing to do is
drag each field to a custom page on the form. You can
then delete those controls and hide the page again. See
http://www.outlookcode.com/d/fields.htm for a lengthier
explanation.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



"Unknown" <[email protected]> wrote in
message news:[email protected]...
 

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