troubleshooting Question

Lotus Notes content mismatch alldocuments in VBA vs. documents visible in UI

Avatar of wekeen
wekeen asked on
Lotus IBM
5 Comments1 Solution855 ViewsLast Modified:
When accessing the documents in a local Lotus Notes database using vba (using vba project reference to domobj.tlb), I have the following two situations with a set of documents returned using dbobject.AllDocuments:

1. There are some documents that I can see via a Lotus Notes 8.5 Client that are not made available as part of the dbobject.AllDocuments NotesDocumentCollection.  These are documents I moved to my local database several months ago.  There doesn't seem to be a pattern other than the fact they seem to be "sent" items of type memo.

2. Documents that I haven't moved to my local Lotus Notes database (and are in fact not visible when accessing my local mail database via a Lotus Notes 8.5 Client) are made available as part of the dbobject.AllDocuments NotesDocumentCollection of my Local mail database.  I've noticed a lot of documents that fit this description.  They seem to be documents of various types (memo, reply, appointment, etc.) that I "sent" from my network resident mail database as recently as the past few days.

Note: There is no replication enabled to my local database.  Documents only move to my local database when I manually move them myself.  

Condensed code snippet used to iterate through all documents in the local database is shown below.  The local database MailDBDocs.Count returns a value of 11,300.  When I check the number of items in the local database using File > Application > Properties in the Notes 8.5 Client, it indicates there are 42,994 documents.  I am assuming the large mismatch is because of deletion stubs, etc.  

I am able to successfully iterate through 11,300 of the documents in the collection and inspect their contents with no problems.

If anyone has insight on these two situations, please let me know.

Public Function searchMail(ByRef dbPwd as string, _
                           ByRef MailServerName as string, _
                           ByRef MailDBName as string, _
                           ByRef MailDB As NotesDatabase, _
                           ByRef Session As NotesSession) As Boolean

Dim MailDB         As NotesDatabase
Dim Session        As NotesSession

Dim MailDBDocs  As NotesDocumentCollection
Dim MailDoc        As NotesDocument
Dim MailItem       As NotesItem

Dim MailDbName     As String
Dim MailServerName As String
Dim tmpString      As String
Dim mdCount        As Long
Dim mdIdx          As Long
Set Session = New NotesSession
Call Session.Initialize(dbPwd)
Set MailDB = Session.GETDATABASE(MailServerName, MailDbName)

Set MailDBDocs = inMailDB.AllDocuments
Set MailDoc = MailDBDocs.GetLastDocument
mdCount = MailDBDocs.Count

For mdIdx = 1 To mdCount
  'code not shown (for brevity of this post) to get doc type/to/from/subject/msgtext here via
  'Set MailItem = MailDoc.GetFirstItem(
  'with arg of "Form", "Subject", "From", "SendTo", "CopyTo", "BlindCopyTo" , etc,

  'Code to inspect From, To, Subject, etc. not shown (for brevity of this post)

  Set MailDoc = MailDBDocs.GetPrevDocument(MailDoc)
  If MailDoc Is Nothing Then
      Exit For
  end if
  If mdIdx > mdCount Then
      Exit For  'Failsafe
  end if

Next mdIdx

End Function
Sjef Bosman
Groupware Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros