Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus Notes Archive Access 1

Status
Not open for further replies.

georgesOne

Technical User
Jul 2, 2004
176
0
0
JP
Hi,

I want to transfer some data into an Access DB. The following code -found here - works well for the active lotus DB.
However, I have records in an archive DB which I would like to add. I can not manage the code to retrieve records from the archive, it always uses the main active DB in which the archive DB is included.

sPathToSave = "C:\DAS\gi\My Documents\LotusDocs\"
Set Session = CreateObject("Notes.Notessession")
Set MailDB = Session.GETDATABASE("C:\DAS\archive\",
"a_gi.nsf")

This is the path/name of an archive DB. The actual DB (which is opened with Lotus Notes) has adifferent path/name

I guess here is the problem.....

Call MailDB.openmail '????????????
Set View = MailDB.GETVIEW("($Inbox)")


Set nDoc = View.GetFirstDocument()
While Not (nDoc Is Nothing)
If nDoc.HasEmbedded Then
Set Itm = nDoc.GETFIRSTITEM("Body")
If Itm.Type = RICHTEXT Then
For Each EmbedObj In Itm.EmbeddedObjects
If (EmbedObj.Type = EMBED_ATTACHMENT) Then
rst.AddNew
rst![DocumentID] = nDoc.GETFIRSTITEM("$Orig").Text
.... and so on ....
rst.Update
EmbedObj.ExtractFile sPathToSave & EmbedObj.Name
End If
Next
End If
End If
End If
Set nDoc = View.GetNextDocument(nDoc)
Wend

Any help is appreciated.

Regards, Georges
 
I finally figured the problem out by myself.
For reference I attach the code with the corrected lines in bold.
The database was local, and I had to access all documents.

sPathToSave = "C:\DAS\gi\My Documents\LotusDocs\"
Set Session = CreateObject("Notes.Notessession")
Set MailDB = Session.GETDATABASE("", "C:\DAS\archive\a_gi.nsf")
Set View = MailDB.ALLDOCUMENTS
Set nDoc = View.GetFirstDocument()

While Not (nDoc Is Nothing)
If nDoc.HasEmbedded Then
Set Itm = nDoc.GETFIRSTITEM("Body")
If Itm.Type = RICHTEXT Then
For Each EmbedObj In Itm.EmbeddedObjects
If (EmbedObj.Type = EMBED_ATTACHMENT) Then
rst.AddNew
rst![DocumentID] = nDoc.GETFIRSTITEM("$Orig").Text
.... and so on ....
rst.Update
EmbedObj.ExtractFile sPathToSave & EmbedObj.Name
End If
Next
End If
End If
End If
Set nDoc = View.GetNextDocument(nDoc)
Wend
 
I don't understand how this codes helps in importing data from Lotus Notes to Access. Does it exist any source sample to do this job?
 
rst stands for an access recordset to be updated.
Code works well.
Regards, Georges
 
I see, but I guess this code is to handle Lotus mail... or not?
I'd like to know how to access a "standard" Notes DB to read data which I will then write to my Access DB.
 
P.S.
In thread thread73-1259335 there's a good example of what I'd like to do.... but which also does not work for me.
 
Jack, why don't you start your own thread, explain your problem, what you've tried, and what didn't work correctly when you tried it.

Thanks
 
Why starting a new thread when already two ones are already present (with no answers...)? :)
And, as it's both a Lotus-side and Access-side issue... it's good there are two topics, one in Access forum and one in Lotus forum.

Anyway, in a few words:
I have a Lotus DB;
I have an Access DB;
I want to synchronize them (from Lotus to Access);
I want to add a button to an Access form to do the job.
 
Why starting a new thread when already two ones are already present (with no answers...)? :)

because you are apparently having a different problem then those other posters!

And it makes it a lot easier for those trying to help you to have a SINGLE location with all YOUR information in it, instead of jumping from thread to thread and getting a piece of information here and another there. Plus wasting people's time by posting an answer in one thread when you have already recieved a solution in another thread.

In thread thread73-1259335 there's a good example of what I'd like to do.... but which also does not work for me.

Now I have to go search another thread to see what you tried and maybe there you posted exactly what didn't work for you.

'Does not work' is not really enough of an explanation to help you. Something like :

I tried this code and when it gets to this line I get the error : {Put error here}

or

I found this document and read it but when it says to do {whatever} I'm not sure how to implement that. I've done _____, _____, _____ and still can't get it to work.

Without you providing DETAILS to what you are doing, you aren't going to get much help.

Leslie
 
[OffTopic]
I can't find the QUOTE button in thisn forum...
[/OffTopic]
...anyway, I'm quite confused now, as while waiting for replies I experimented a bit with Notes/Access, and found that there are two "class modules" (don't know the proper name) to refer to: LOTUS and NOTES ; I can "connect" to LOTUS by Tools/References menu in Access, but I can't do the same for NOTES.... but looks like I can access to NOTES properties from Access, but not to LOTUS properties....

THis code raises an "undefined object error" on line "set db..."
Code:
    Dim session As NotesSession
    Dim db As NotesDatabase
    
    Debug.Print session.CURRENTDATABASE
     Rem Opened Database
    Set db = session.GetDatabase("", "names.nsf")
    
    If Not db.IsOpen Then
        MsgBox "database cannot be opened", , "cannot opened"
    Else
        MsgBox db.Title, , "opened"
    End If

Adding this line I get a "type mismatch error":
Code:
    Set session = CreateObject("notes.notessession")

This code seems to be working...
Code:
    Dim session As Object
    Dim db As Object
    
    Set session = CreateObject("notes.notessession")
'    Debug.Print session.CURRENTDATABASE
     Rem Opened Database
    Set db = session.GetDatabase("", "names.nsf")
    
    If Not db.IsOpen Then
        MsgBox "database cannot be opened", , "cannot opened"
    Else
        MsgBox db.Title, , "opened"
    End If
but then I don't know how to go on to access Lotus documents and read their fields.

Quite a mess.

"Unfortunately" I'm going on holydays within 10 minutes and I'll have no access to Notes for some weeks... I hope I'll find some useful tips upon coming back here around. ;-)
 
This should give you a start....

Sub GetSamples()
'This code can be used to update any Lotus database

Dim Session As Object
Dim MailDB As Object
Dim View As Object 'New Domino.NotesView
Dim nDoc As Object 'Domino.NotesDocument
Dim Itm As Variant
Dim dbs As DataBase
Dim rst As Recordset

Set dbs = CurrentDb(or your Access DB)
Set rst = dbs.OpenRecordset("Your table", dbOpenDynaset)

Set Session = CreateObject("Notes.Notessession")
Set MailDB = Session.GetDatabase("Your server", "Your lotus db.nsf")
Set View = MailDB.AllDocuments
Set nDoc = View.GetFirstDocument() '1247
While Not (nDoc Is Nothing)
rst.MoveFirst
rst.FindFirst ("[UniversalID] = '" & nDoc.UniversalID & "'")
If rst.NoMatch Then
rst.AddNew
rst![xaxaxa] = MailDB.ReplicaID
rst![xbxbxbxb] = nDoc.UniversalID
For Each Itm In nDoc.Items
Select Case Itm.Name
Case Is = "xxxxx" : rst![yyyyy] = Itm.Text
End Select
Next
Else
'Not relevant code
End If
Set nDoc = View.GetNextDocument(nDoc)
DoEvents
Wend

rst.Close
dbs.Close
Set rst = nothing
Set dbs = Nothing

End Sub

regards, Georg
 
Thank you very much for the source!
I guess "items" are "fields" of Notes "database"...
I'll try the program as soon as I go back to my office.

In the meantime, can you tell me where to find informations about method/properties exposed by Lotus, and their use?
I found the document I linked above, but it's very complex; rather than just parsing ALL documents (like in your source), maybe parsing documents within an existing view would be faster, but I don't know how to accomplish this.

-- Jumpjack --
 
I eventually tested your source, and it works fine! Thanks.

But, I can only see the contents of the "fields": how can I read their names?

-- Jumpjack --
 
But, I can only see the contents of the "fields": how can I read their names
You mean Itm.Text and Itm.Name ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yes.
Thanks, I eventually found a PDF from IBM with a complete reference of available class, methods and properties.
Don't remember the link right now, it's on my office PC...
Just look for "lotus COM programming" or similar.

-- Jumpjack --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top