0 pts.
 Moving documents to a folder
Can someone tell me how to write an agent that will select ONLY about 3000 the oldest documents in the inbox and move them to a folder?

Software/Hardware used:
ASKED: June 8, 2006  10:35 AM
UPDATED: June 8, 2006  11:16 AM

Answer Wiki:
Do you really need an agent to do what either Rules (within the mailfile) or Archiving (to a local archive) will do for you? Not enough info here.
Last Wiki Answer Submitted:  June 8, 2006  11:04 am  by  Jlnewmark   0 pts.
All Answer Wiki Contributors:  Jlnewmark   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Your solution in in the NotesViewEntryCollection class using the PutInFolder Method.
You can cut and paste this code but suggest you add some print statements so you can see it run. If your mailbox has 10k messages like mine it will take a bit to run!
Good luck – Mike
*************************
%REM
This code will read your inbox and dump half its entries into a folder called “Cheese”.
%END REM

Sub Initialize
Dim s As New notessession
Dim db As notesdatabase
Dim v As notesview
Dim vec1 As notesviewentrycollection
Dim vec2 As notesviewentrycollection
Dim ve As notesviewentry

Set db = s.currentdatabase
Set v = db.GetView(“($Inbox)”)
count% = v.entrycount
%REM
this will get about half your inbox,
you can figure out how to get exactly 3000 if that’s what you want,
count the view to make sure you have at least that many entries and
then use the GetLastEntry method and work backwards to get your collection
%ENDREM
If count% Mod 2 = 0 Then
n& = count%/2
Else
n& = (count% – 1)/2
End If
Messagebox Str(n&)
Set vec1 = v.AllEntries
Set ve = vec1.GetNthEntry(n&)

While Not ve Is Nothing
n& = n& + 1
If n& > count% Then Goto finito ‘ this avoids the out of range error at the end of the loop
Call vec2.AddEntry(ve)
Set ve = vec1.GetNthEntry(n&)
Wend
finito:
Call vec2.PutAllInFolder(“Cheese”)
End Sub

 35 pts.