Hello,
I would like to set up an agent that moves messages from one public folder to another (one level down). My problem is to get the target folder identified. The script allways moves the message to the parent folder.
Thanks for any help.
Here is my code:
<SCRIPT RunAt=Server Language=VBScript>
'----------------------------------------
' Event Handlers
'----------------------------------------
' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnTimer
Dim i
Dim objSession
Dim objFolder
Dim objDestinationFolder
Dim objDestFolder
Dim objMovedMessage
Dim oMessages
Dim oMessage
Dim status
Set objSession = EventDetails.Session
Set objFolder = objSession.GetFolder (EventDetails.FolderID, Null)
Set oMessages = objFolder.Messages
Set objDestinationFolder = objFolder.Folders("TestSubFolder")
Set objDestFolder = objSession.GetFolder(objDestinationFolder.FolderID, Null)
WriteResponse("Folder found")
for i = 1 to oMessages.Count
Set oMessage = oMessages.Item(i)
status = oMessage.Fields("Status")
If status = "ready" then
Set objMovedMessage = oMessage.MoveTo(objDestFolder.FolderID)
WriteResponse("Move successful!")
End If
next
Set objSession = Nothing
Set oMessage = Nothing
Set objFolder = Nothing
Set objMovedMessage = Nothing
End Sub
'------------------------------------------------------
' Private Subs
'------------------------------------------------------
Private Sub WriteResponse(strLogMessage)
Script.Response = Script.Response & vbNewLine & Now & " >" & strLogMessage
End Sub
</SCRIPT>
I would like to set up an agent that moves messages from one public folder to another (one level down). My problem is to get the target folder identified. The script allways moves the message to the parent folder.
Thanks for any help.
Here is my code:
<SCRIPT RunAt=Server Language=VBScript>
'----------------------------------------
' Event Handlers
'----------------------------------------
' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnTimer
Dim i
Dim objSession
Dim objFolder
Dim objDestinationFolder
Dim objDestFolder
Dim objMovedMessage
Dim oMessages
Dim oMessage
Dim status
Set objSession = EventDetails.Session
Set objFolder = objSession.GetFolder (EventDetails.FolderID, Null)
Set oMessages = objFolder.Messages
Set objDestinationFolder = objFolder.Folders("TestSubFolder")
Set objDestFolder = objSession.GetFolder(objDestinationFolder.FolderID, Null)
WriteResponse("Folder found")
for i = 1 to oMessages.Count
Set oMessage = oMessages.Item(i)
status = oMessage.Fields("Status")
If status = "ready" then
Set objMovedMessage = oMessage.MoveTo(objDestFolder.FolderID)
WriteResponse("Move successful!")
End If
next
Set objSession = Nothing
Set oMessage = Nothing
Set objFolder = Nothing
Set objMovedMessage = Nothing
End Sub
'------------------------------------------------------
' Private Subs
'------------------------------------------------------
Private Sub WriteResponse(strLogMessage)
Script.Response = Script.Response & vbNewLine & Now & " >" & strLogMessage
End Sub
</SCRIPT>