I am trying to design a button which will create a new calendar entry in the mail file of the person who clicks it. The button will reside in a form within another database.
The problem is, most of the code I see for this sort of lotusscript assumes the button would reside in the actual user’s mail db, and so they use the following to set the db:
Set db = session.CurrentDatabase
The remainder of the script basically takes into account that this variable is set.
Is there some code I can substitute for this, to set the db variable, but so that it is pointing to the mail file of the active user?
Thanks in advance for any help.
Subject: Button to create calendar entry in another mail db
You can get the user’s mail file information from the notes.ini
Something like this:
envstring = sess.GetEnvironmentString( “Location”, True )
location = Left$( envstring, Instr( envstring, “,” ) - 1 )
mailserver = sess.GetEnvironmentString( “MailServer”, True )
mailfile = sess.GetEnvironmentString( “MailFile”, True )
set db = new NotesDatabase( mailserver, mailfile )
Subject: RE: Button to create calendar entry in another mail db
Hi Martha, thanks for that code! I added it to my script, and we’re making some progress. Only thing I don’t understand is:
location = Left$( envstring, Instr( envstring, “,” ) - 1 )
I think this is setting the name of the current location document? But how/where is that used? I am using a local replica of my mail, and my location document points to that local file. When I click the button (after adding your code), I get the following message:
Database SERVERNAME!!mymail.nsf has not been opened yet
(SERVERNAME above will show the actual name of my mail server)
Subject: RE: Button to create calendar entry in another mail db
OpenMail method
Assigns a database to the current user’s mail database and opens that database.
Defined in
NotesDatabase
Syntax
Call notesDatabase.OpenMail
Usage
If the script runs on a workstation, OpenMail finds the current user’s mail server and database in the notes.ini (or Notes Preferences) file.
Subject: RE: Button to create calendar entry in another mail db
Thanks for the suggestion. I tried using this before I posted, but the problem I ran into was that I needed to set a variable which defines the actual mail file. If there were an easy command like session.CurrentDatabase which could be used to grab the mail file location/details of the active user, that would be very useful.