Take the 2-minute tour ×

I send mails from C# code via Lotus Notes and it works really fine - with Win7 and WinXP.

But some users of my program have multiple .nsf files in the directory, like 'user1.nsf' and 'old-user1.nsf'.

How can I retieve which of these files is the active database I have to use?

share|improve this question
add comment

3 Answers

If your code runs on users machine then you have "MailFile" and "MailServer" variables in notes.ini file.

Where is this directory located?

share|improve this answer
Yes, thank you! I found it. And I read it with following code: ' Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession"); Object sess = Activator.CreateInstance(NotesSession); String mailFile = (String)NotesSession.InvokeMember( "GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true }); ' –  Martin S Mar 1 '13 at 13:28
add comment

You don't need to care which mail database is active if you are sending emails. Just create a new NotesDocument object in memory, fill out the appropriate properties (subject, Body, etc), and then call the Send method on that object. Notes takes care of the rest.

If you need to get the mail database information for a user for another reason, there is a GetUserInfo method for that on the NotesRegistration class

Or in formulas, there is the @MailDbName formula.

share|improve this answer
add comment

If you're just using the user's mail file, in LotusScript you can just use

Call notesDatabase.OpenMail

That way, you never need to bother with where the mail file is - you get the handle to it seemlessly.

share|improve this answer
add comment

Your Answer


