Change message class in PF with agent

R

rfalken

Hello folks,

Any idea why the if statement in this code snippet doesn't work? If
remove the if statement it works. This is a cut down version of th
code from CDOLive....


' DESCRIPTION: This event is fired when a new message is added to th
folder
Public Sub Folder_OnMessageCreated

Dim oSession ' Session
Dim oCurrentMsg ' Current message
Dim oFolder ' Current folder
Dim NewMC ' New message type

' Clear error buffer
Err.Clear

' Get session informationen
Set oSession = EventDetails.Session

' Write some logging
Call DebugAppend(oSession.CurrentUser & " ChgMsgCl - Proccessin
started", False)

' Get current folder
Set oFolder = oSession.GetFolder(EventDetails.FolderID,Null)

' Get current message
Set oCurrentMsg = oSession.GetMessage(EventDetails.MessageID,Null)

' Set current message to read
oCurrentMsg.Unread = False

' Remember subject of arrived message
Call DebugAppend("New message with subject: <" & oCurrentMsg.Subject
"> arrived", False)

NewMC = "IPM.Note"

If oCurrentMsg.Type = NewMC Then
' Change the Message Class
Call DebugAppend("Message Type : <" & oCurrentMsg.Type & "> "
False)
oCurrentMsg.Type = "IPM.Note.NewSalesForm"
' Save the changed item
oCurrentMsg.Update
Call DebugAppend("Updated Message Type : <" & oCurrentMsg.Type & "> "
False)
'End If


' Release objects
Set oSession = Nothing
Set oCurrentMsg = Nothing
Set oFolder = Nothing


' Write results in the Scripting Agent log
Script.Response = g_bstrDebug
End Sub

' DESCRIPTION: This event is fired when a message in the folder i
changed
Public Sub Message_OnChange
'Not used
End Sub

' DESCRIPTION: This event is fired when a message is deleted from th
folder
Public Sub Folder_OnMessageDeleted
'Not used
End Sub

' DESCRIPTION: This event is fired when the timer on the folde
expires
Public Sub Folder_OnTimer
'Not used
End Su
 
S

Sue Mosher [MVP]

You might want to write the message class of the item out to your debug log file to find out what it is, since that's the problem point. My guess is that the class is actually IPM.Post, not IPM.Note.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
R

rfalken

In the if statement the value being matched for is incorrect.

IPM.NOTE does not equal IPM.Note
 
S

Sue Mosher [MVP]

Your latest message doesn't have much detail, so I don't know what this is
all about, but you probably just need to adjust your code so you're
comparing upper case with upper case:

If UCase(whatever) = "IPM.NOTE" Then
 

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