This Placebot moves any emails in the index folder into another folder called "Emails In" .
This can be changed in the code.
The code can be fiddled to prevent the documents being reset to the folder all the time by storing a "ProcessedByInboxAgent" field on the document.
Option Public
Sub Initialize
' Placebot code by Adam Foster July 2008
' Please check http://NotesNinjas.com/#PlacebotMoveEmail for latest versions
Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
Dim v As notesview
Set v= db.GetView("System\Index")
Dim doc As notesdocument
fname="Emails In"
Dim vf As notesview
Set vf=db.GetView(fname)
If vf Is Nothing Then
Print "Move emails Placebot: Cannot find folder '" & fname & "' in " & db.filepath
End
End If
Dim agentlog As New NotesLog("AgentLog")
Call agentLog.OpenAgentLog
Set doc=v.GetFirstDocument()
Do Until doc Is Nothing
If doc.HasItem("Sendto") Then
'ok got one
agentlog.logaction("checking " & doc.subject(0))
If doc.HasItem("h_folderunid") Then
'ok already in a folder
If doc.h_folderunid(0) <> v.UniversalID Then
agentlog.logaction("Changing " & doc.subject(0) & " to folder " & fname & " ... ")
Call doc.replaceitemvalue("h_folderunid",v.UniversalID)
Call doc.PutInFolder(fname)
Call doc.Save(True,False)
agentlog.logaction("Saved " & doc.subject(0) & " to folder " & fname)
End If
agentlog.logaction("document already has the h_folderunid field")
Else
agentlog.logaction("Moving " & doc.subject(0) & " to folder " & fname & " ... ")
Call doc.replaceitemvalue("h_folderunid",v.UniversalID)
Call doc.PutInFolder(fname)
Call doc.Save(True,False)
agentlog.logaction("Saved " & doc.subject(0) & " to folder " & fname)
End If
End If
Set doc = v.GetNextDocument(doc)
Loop
Call agentLog.Close
End
eh:
agentlog.logaction("Error: " & Error$ & " at line " & Erl)
Call agentLog.Close
End
End Sub
Save the above code into a text file using notepad and call it MoveEmail.lss or something.
Create your folder "Emails In" or whatever you change fname to in the code above.
creat your placebot, and pick the lss file.
Set it to run every 10 minutes or so.
After saving, you can select the placebot, then do a "Run Placebot" from the more options action button.
Hope this helps you write more placebots. If so please share them with me.