Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a MessageClass in Outlook

Status
Not open for further replies.

cthaxter

Programmer
Aug 2, 2001
71
US
I'm trying to automate changing a message class in an Outlook form. Here's the problem.

Let's say I create a user-defined field from the All Fields tab in a contact, called IntroLetterSent. I'm using a form with the message class "IPM.Contact.ITU" on a public contacts folder called the "Blue Book". I've set that folder to always post items to that folder using the ITU form.

However, every time I change the value of IntroLetterSent on a contact in this folder, the message class is somehow mysteriously and automatically changed to the standard "IPM.Contact", and the contact item still posts. If you know how to get around this, and have a user-defined field that is not attached to any form post using a specific form and message class, then let me know--that would be the real solution.

But in the meantime, here's what I need to do. I need to put some VBScript in the form (using the "View Code" screen from the Form menu in Form Design View) that will execute probably on close. I'm not familiar enough with code syntax to write this, so I need some help. Here's what I have so far:

Code:
Sub Item_Close
   NewMC = "IPM.Contact.ITU"
   If Item.MessageClass <> NewMC Then
      Item.MessageClass = NewMC
      Item.Save
   End If
End Sub

One problem is that I don't know exactly on what event the message class is automatically changed in the scenario above. I think it's pretty late. Will &quot;Sub Item_Close&quot; cause the routine to execute once the item is closed? And do all my &quot; Item.* &quot; codes have the correct syntax?

I haven't tried it yet, but in this case I'd rather ask first and then try it.

Thank you in advance.

Christopher
 
I just realized, by the way, that using &quot;Item&quot; like that probably won't work. Should I change it to a variable such as &quot;CurrentItem&quot; and set CurrentItem to be the currently open item? What's the code for that?

I'll need to keep my events straight, too. If I assign CurrentItem to the currently open item, and this code executes on close--does the code execute just before closing or just after closing? Will the variable be set correctly? Or does this consideration not matter in this case?

I hope I've clarified my question a bit.

Christopher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top