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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using NotesView GetFirstDocument & GetNextDocument is too slow

Status
Not open for further replies.

MikeSanders

Programmer
Aug 5, 2003
1
US
Hello,

I have successfully created a Visual Basic application which allows the end user to use Lotus Notes to send an e-mail using a late-bound COM interface. However, I have an issue related to the time it takes to retrieve a list of 1,000+ Notes e-mail addresses using the NotesView class GetFirstDocument and GetNextDocument methods. It can take more than 10 seconds to retrieve a list of 1000 e-mail addresses via the NotesView class methods. Is there an alternative method which would be faster?

Here is a VB code snippet to help describe my situation:

Dim oSess As Object
Dim oView As Object
Dim oDoc As Object
Dim v As Variant
Dim var As Variant
Dim lAddr As Long
Dim lAddrCount As Long
Dim sAddress() As String
Dim vTmps() As Variant

var = oSess.ADDRESSBOOKS
'open each address book
For Each v In var
v.Open "", ""
'if address book is "PUBLIC" then
If v.Title Like "*PUBLIC*" Then
'get all documents within the "People" view
'note: each document within the "People" view contains a valid e-mail address
Set oView = v.GETVIEW("People")
'determine # of people and initialize array
lAddrCount = oView.TopLevelEntryCount
ReDim sAddress(lAddrCount)
'find first person
Set oDoc = oView.GETFIRSTDOCUMENT
Do While Not oDoc Is Nothing
vTmps = oDoc.COLUMNVALUES
'add person's name to array
lAddr = lAddr + 1
sAddress(lAddr) = vTmps(0)
Set oDoc = oView.GETNEXTDOCUMENT(oDoc)
Loop
Exit For
End If
Next

Thank you,
Mike Sanders
 
I haven't tried connecting to notes with any other program like you have, except Access (and just linked, so it was easy) but I might have an answer...

I've found that NotesDocumentCollection objects are great to work with, and easier to enumerate - as long as you can get your hands on one.

One way you can do it, is to use the Search method of the Database Object, but that's a pain, because you have to supply a NotesDateTime object (even if it's set to "", i.e. SetAnyDate and SetAnyTime). Not worth it.

I have a better solution for you though- don't work with the "People" view, but with the "($VIMPeopleAndGroups)" view. You can key off the first column, which is a single letter, designating Type: P(erson) or G(roup)

I'm not quite sure how to completely convert the LotusScript into VB, but, this is how I'd get the values of names in LS.

Code:
Dim Sess as NotesSession
Dim DB as NotesDatabase
Dim View as NotesView
Dim DocCol as NotesDocumentCollection
Dim Doc as NotesDocument

Set Sess = New NotesSession
set DB = Sess.OpenDatabase("
server$
Code:
", "
dbFile$
Code:
")
set View = DB.GetView("($VIMPeopleAndGroups)")
Set DocCol = V.GetAllDocumentsByKey("P")

Set Doc = DocCol.GetFirstDocument

While Not Doc Is Nothing
    'do whatever you want with the doc object
    Set Doc = DocCol.GetNextDocument(Doc)
Wend

' Clean up
Set DocCol = Nothing
Set View = Nothing
Set DB = Nothing
Set Sess = Nothing

I haven't done a comparison check, but my guess is this- by doing it this way, you're grabbing an entire collection of documents at once and working on each at a time- instead of going out, grabbing one, working with it, then going out and grabbing the next.

Hope this helps, and I hope it solves the problem.

Let me know! [8O)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top