Add Agent from one Db to another Db

Greetings everyone,

I’m trying to copy an agent from one Notes database to another Notes Database using the NotesNoteCollection. But I’m getting a notes error message “The specified note or note does not exist in the collections’s parent database”.

Here is the code:

Dim nc As NotesNoteCollection

Dim ncTW As NotesNoteCollection

Dim db As New NotesDatabase(“”,“”)

Dim dbTeamWorks As New NotesDatabase(“”,“”)

Dim agent As NotesAgent

Dim doc As NotesDocument

Call dbTeamWorks.OpenByReplicaID(“R5DEV03”,“852570AE00610F96”)

Call db.OpenMail

Set nc = db.CreateNoteCollection(False)

nc.SelectAgents = True

Call nc.BuildCollection

Set ncTW = dbTeamworks.CreateNoteCollection(False)

ncTW.SelectAgents = True

ncTW.SelectionFormula = “$TITLE=”“Copy Documents to TeamWorks”“”

Call ncTW.BuildCollection

nid = ncTW.GetFirstNoteId

Set doc = dbTeamWorks.GetDocumentByID(nid)

Call nc.Add(doc)

Any Help would be greatly appreciated.

Thanks,

Oscar J. Kerrebyn

Subject: Add Agent from one Db to another Db

You’d have to use CopyToDatabase to move the agent from one database to the other – the NotesNoteCollection can only contain documents that exist in the database. As far as I can see, you don’t need to create the collection in the mail database – just select the agents you want in the Teamworks database, get the agents as documents, then use CopyToDatabase to move the agent over.

Subject: RE: Add Agent from one Db to another Db

Thank you Stan, you’re a gentleman and a scholar! I’m new to R6 (4YRS with R5) so it will take some time to learn the new script objects.

Thanks Again,

Oscar J. Kerrebyn