
To change an item's message class with an Exchange Server script (solution)
This is follow up regarding my original post. After posting my
request for help, I spent more time searching for answers in the
newsgroup and finally got the script to work. Since I am not an
accomplished script writer, I thought I would share with others what I
did to get this simple script to work.
1. Part of the problem was simply carelessness on my part. When I
created the script in one of my Outlook public folders, I chose the
wrong Exchange Server. My folder had only one replica and I did not
initially check in Exchange Administrator to see which Exchange Server
stored the public folder. Once I chose the right server, I started to
get MicrosoftES messages in the event viewer of my Exchange Server
under applications. However my script still did not work.
2. I discovered that I was missing a small piece of code that I did
not see when I first found the script. The code is: objItem.Unread =
TRUE. I don't know why this makes a difference, but it did. Here's
my code now:
----Cut here-------
<SCRIPT RunAt=Server Language=VBScript>
'------------------------------------------------------------------------------
'FILE DESCRIPTION: Exchange Server Event Script
'------------------------------------------------------------------------------
Option Explicit
'------------------------------------------------------------------------------
' Global Variables
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' Event Handlers
'------------------------------------------------------------------------------
Public Sub Folder_OnMessageCreated()
Dim objSession
Dim objItem
Dim strMessageClass
Dim objFolder
strMessageClass = "IPM.Note.It Request Form"
Set objSession = EventDetails.Session
Set objItem = objSession.GetMessage(EventDetails.MessageID, Null)
If objItem.Type <> "IPM.Note.IT Request Form" Then
objItem.Type = "IPM.Note.IT Request Form"
objItem.Unread = True
objItem.Update
End If
Script.Response = FormatDateTime(Now()) & _
objItem.Subject & " updated to " & _
objItem.Type
Set objSession = Nothing
Set objItem = Nothing
End Sub
</SCRIPT>
----Cut here------
Now I am in business. I would be interested in knowing why
"objItem.Unread = TRUE" made a difference.
Thanks.