Link to home
Start Free TrialLog in
Avatar of wekeen
wekeen

asked on

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

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)
MailDB.OPENMAIL

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
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

First off, the assumption is wrong: deletion stubs do not count as documents.

Possible explanations for the odd behaviour:
- you are opening different databases in the Notes client and in VBA; just a check: can you print the database's server, filepath and replicaId properties?
- if you think I'm not taking you seriously: did you know that the OpenMail method does NOT open the database object you just created? It opens the current mail database as specified in the notes.ini file, which is usually a reflection of the mail database specified in the current Location document. What's strange is that the Help says about this method that "This method is supported in LotusScript only." and you seem to be successfully using it in VBA.
- then there could be problems with view indexes and corrupted design elements. You could treat the first with a Ctrl-Shift-F9, it will recreate ALL views in the database. Corruptions can be eliminated using Compact and Fixup.

I won't bet my hat on it, but I do think there is a very high probability that you're opening different database.
Avatar of wekeen
wekeen

ASKER

sjef,

Thanks for your reply.  When I condensed the code I failed to mention that the MailDB.OPENMAIL statment is only exectuted if MailDB.isOpen = false.  isOpen is always = True after I call Session.GETDATABASE so I never call OPENMAIL.  Apologies for the misinformation on my part.

I am able to successfully query the database server, filepath and replicaId properties.  Server is a null string, filepath contains the full local path including the name of my local .nsf database file.  ReplicaID has a long string of numeric characters in it.  I should note that after reading your reply I ran a test while disconnected from the server that contains my non-local mail database and it didn't change the outcome.

I did run a Compact and used Ctrl-Shift-F9 to recreate all the views.  Alas, I still am seeing the same phenomenon.  Some of the documents I can see and open in my All Documents view of my local database file in from the Notes 8.5 Client aren't included in the AllDocuments collection via VBA.  Also still seeing about 250 mail documents in AllDocuments collection that I cannot see from the Notes 8.5 Client.

Thanks again for your reply.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wekeen

ASKER

Sjef,

Well I have to say a big "Thank You" for your help.  After your last post I went back and double checked the replicat id and sure enough, they're not the same.    I just didn't look closely enough ... they're nearly the same except for the last several digits of the string.  A fact I should have noticed.  The actual file name wasn't visible in the Notes Client - since it runs off the end of the display field in the File > Application > Properties  window.

I realized what was happening only by digging a lot deeper and searching my entire hard drive for a file of any name that a similar size to the one shown in the properties window.  The file is the local mail file so it didn't even have an nsf extension on the end.  I wouldn't have known exactly what to look for without your help pointing me to obvious... not the same mail database.  

Thank you again!
:-)) Splendid! And, once again, my hat is safe.