An agent to copy contact from inotes databases to another one

Hello all,

need some insight as to what code to use and how should I go about doing this. I need to write and agent for a mail-in database (or just a generic database that shows contact information) that copies the inotes contacts from other databases (368 to be exact) and pulls them into the database the agent is running from.

any insights?

Subject: an agent to copy contact from inotes databases to another one - CopyToDatabase method ? Look in the Designer help

Subject: copy docs from many to one

ok i’ve gotten this far from the help. this is to copy documents from one database to another. but what is the best approach to copy documents from $Contacts view to one database (the one with the agent) from multiple databases (365) of them. is there a function that I can do for this? been looking can’t find anything

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim db2 As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set db2 = New NotesDatabase _

(“”, Inputbox(“Name of database file?”))

Call db.UpdateFTIndex(True)

Set dc = db.FTSearch(“Acme”, 0)

Set doc = dc.GetFirstDocument()

While Not(doc Is Nothing)

 'Use the call statement because to return

 'value is needed

 Call doc.CopyToDatabase(db2)

 Set doc = dc.GetNextDocument(doc)

Wend

End Sub

Subject: exemple

An example. it’s not complete

Set currentDb = session.CurrentDatabase

Set db = s.GetDatabase(s.CurrentDatabase.Server, “names.nsf”)

Set view = db.GetView(“Mail Users”)

server = “Your mail server here”

Set dc = view.GetAllDocumentsByKey(server, False)

If dc.Count = 0 Then

Print "No user on that server"		

Exit Sub

End If

Set doc = dc.getfirstdocument

While Not(doc Is Nothing)

Set dbMailuser = New NotesDatabase(doc.MailServer(0), doc.MailFile(0)+ “.nsf”)

You copytodb here

Set doc = dc.getnextdocument(doc)

Wend

Subject: copying all documents from multiple databases to the server with the agent running on it

ok this is my code. I am comming up with an error when I run the agent “variant has no object”

I know that you can concatenate a variant that is a number and a string. so what am I missing?

Sub Initialize

Dim session As New NotesSession

Dim currentDB As NotesDatabase

Dim db As Notesdatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Set currentDB = session.CurrentDatabase

server = “server1/independent”

Dim AvariantV As Variant

AvariantV = 10

For AvariantV= 10 To 12

Set db = s.GetDatabase.server( “store0” + AvariantV +“.nsf”)

Set view = db.GetView(“($Contacts)”)

Set dc = view.getAllDocuments()

Set doc = dc.GetFirstDocument().copytodatabase(currentDB)

While Not(doc Is Nothing)

Set doc = dc.GetNextDocument(doc).copytodatabase(currentDB)

Wend

Next

End Sub