I almost have this defeated. I wrote an agent that copies documents from the contacts view from multiple source databases to a destination database. the agent is running on the destination database. the problem I am having now is I am getting an error message that states the source database is not open. does anyone know what method or function I need to use to copy the documents in a closed mail file over the the open mail file the agent is running on?
here is my code:
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
Dim AvariantV As Variant
AvariantV = 10
For AvariantV= 10 To 12
Set db = session.GetDatabase("server1/independent", "filename0" + 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
Subject: RE: copy documents from a closed mail file to an opened one (part 2)
ok I corrected the problem. the parameters for âcontactsâ I had to leave the $ sign out. now I get the error after the scrip is run, âobject variable not setâ. I see that is found 54 documents in the view from the source database but nothing was copied into the destination database where the agent is run from.
here is the agent log:
Started running agent âget contactsâ on 11/03/2008 01:27:28 PM
Running on new or modified documents: 54 total
Found 54 document(s) that match search criteria
Ran LotusScript code
Done running agent âget contactsâ on 11/03/2008 01:27:29 PM
Subject: RE:RE: copy documents from a closed mail file to an opened one (part 2)
understood. I made removed the get alldocuments class and added the view class. I am still getting the same error at the same place. hereâs my updated code:
Sub Initialize
Dim session As New NotesSession 'gives script access to destination database'
Dim currentDB As NotesDatabase
Dim db As Notesdatabase
'Dim dc As NotesDocumentCollection REMOVED'
Dim doc As NotesDocument
Dim view As NotesView
Set currentDB = session.CurrentDatabase
Dim AvariantV As Variant
AvariantV = 10
For AvariantV= 10 To 12
Set db = session.GetDatabase("server1/independent", "mail/" + "file0" + AvariantV +".nsf")
If db.IsOpen Then 'checks to see if destination database is opened
Set view = db.GetView("Contacts")
'Set dc = view.getAllDocuments() REMOVED'
Set doc = view.GetFirstDocument()
Call doc.CopyToDatabase(currentDB)
Else
Call db.open("stwebmail/brookstone", "store0" + AvariantV +".nsf") 'if database is not opened, open it
Set view = db.GetView("Contacts")
'Set dc = view.getAllDocuments() REMOVED'
Set doc = view.GetFirstDocument()
Call doc.CopyToDatabase(currentDB)
End If
While Not(doc Is Nothing)
Set doc = view.GetNextDocument(doc)
Call doc.CopyToDatabase(currentDB)
Wend
Next
If you do this, it forces you to declare your variables. And if you declare your variables to their actual types (not Variant), then the compiler can tell you when you try to use a method, such as getalldocuments, that doesnât exist. Read about NotesView in the Designer help. Where do you see this method described?
Andre you were correct! I got it with also a some help from my friend Chris. Thanks all of you guys. I certaintly hope that I will eventually possess the master expertise that you all have exhibited.