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!

Move message to public folder agent

Status
Not open for further replies.

sbauerle

Technical User
Mar 14, 2002
17
DE
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>
 
Hello sbauerle,

To get to the folder's entry ID, you have to replace everywhere .FoldersID by .ID. For instance,
Set objFolder = objSession.GetFolder (EventDetails.FolderID, Null) [red]'_wrong_[/red]
should be read as:
Set objFolder = objSession.GetFolder (EventDetails.ID, Null)
etc.

regards - tsuji

 
Hello tsuji,
thanks for your help. It works just fine.
regards
Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top