Random observations of a very experienced software artist.

    Obtaining mail.box in LotusScript

    John McCann  July 24 2010 12:00:00 PM
    Well, I finally tracked down another bug that has been plaguing me - failures in opening the mail.box database directly.

    In a WebQuerySave agent for a form,  I was sending MIME formatted email messages.  As is a commonly documented technique, I open the server mail.box directly and created the Notes document directly there.  When we upgraded from Domino 8.0.2 to 8.5.1 on the development systems (never tried 8.5), these agents failed.  The failure was that the database was not open.    I had been using a construct similar to the following to set the NotesDatabase variable:

    Set dbMail = session.GetDatabase(session.currentdatabase.server, "mail.box",false)
    If dbMail is Nothing then
          Set dbMail = session.GetDatabase(session.currentdatabase.server, "mail1.box",false)
    End if

    This code had been running merrily since Domino 6.x and probably before.  In Domino 8.5.1 it fails.  The variable dbMail is "Nothing".     The first time I ran into this, I used the quick workaround of the complete file path:

    Set dbMail = session.GetDatabase(session.currentdatabase.server, "c:\lotus\domino\data\mail.box",false)

    I knew this was bad, but needed something quick.

    I spent some time today exploring the known problem of the format of Notesdatabase.server being unpredictable.  It may be flat, abbreviated, or canonical depending on the phase of the moon.  IBM's announced intention is to never fix the unpredictability.  I found that my problem wasn't dependent on the format of the server name field even though I believed the relationship between moon phases and what is returned has changed between releases.

    But, this led me to the "duh" moment.  Why am I passing server name in the first place?  The agent runs on the server.  I only want the mail box on that server.  So, take the server name out.  The code is now as shown below and works like a champ, independent of data directory location, on servers with and without multiple mail boxes.

    Set dbMail = session.GetDatabase("", "mail.box",false)
    If dbMail is Nothing then
          Set dbMail = session.GetDatabase("", "mail1.box",false)
    End if

    This also solve a problem I had been seeing on the console

    Error connecting to server XYZZY, Remote system no longer responding.

    This message was the result of attempting to open the mail.box file on the same server.  Removing the server name from the getDatabase eliminates this message..

    No Comments Found