0
votes

I am working on a Java program to send emails with attachments through the lotus notes client. A coworker gave me a vba script capable of this task to orientate myself. The script is following:

Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GetDatabase("", MailDbName)

Like magic this successfully opens the local notes database file and I am able to send emails. Now I tried to replicate this in Java with the Lotus Notes API "Notes.jar":

Session s = NotesFactory.createSession();
Database database = s.getDatabase("", "PATH TO NSF FILE");

If I give the getDatabase method the exact path to the nsf file it works like a charm but giving it the same value as MailDbName from the vba script it doesn't work. My question is how does this work in vba but not in Java? Giving the getDatabase method the exact path doesn't work on any other device except my own one. So how do I get this working on any device?

Many thanks!

1
Please show the exact code that doesn't work. Don't make us guess. I.e., show us exactly how you are giving it "the same value of MailDbName from the vba script". Also please tell us: on what machine is the VBA script running, and how is it being run; and on what machine is the Java code running, and how is it being run?Richard Schwartz

1 Answers

1
votes

If you have a local mailfile replica, it usually lives in the Notes/Data directory, which is considered the root directory for Notes. That is why it opens in the first example. In the second example it sounds like the database you are trying to open is in a folder within the Notes/Data directory, that is probably why it is not working.

Normally when you want to open a mail database, you use the openMailDatabase method of the DbDirectory class if you use Java and the OpenMail method of the NotesDatabase classs from Lotusscript.