hcl-bot
November 21, 2007, 2:13am
1
I am currently working on a project and I want to connect to local Lotus Notes to send mail.Thre following is my code.
public class StartRobot extends NotesThread
{
public static void main(String argv )
{
new StartRobot().start();
}
public void runNotes()
{
try
{
Session notesSession = NotesFactory.createSession();
System.out.println(notesSession.getUserName());
// Operational code goes here
Database mailDatabase=notesSession.getDatabase("shc380wim01/Shanghai/americanexpress","myname.nsf");
mailDatabase.open();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
When i run the codes, I will get an Exceptiong as below:
Database open failed (%1)
at lotus.domino.local.Database.Nopen(Native Method)
at lotus.domino.local.Database.open(Unknown Source)
at lotusnotesrobot.StartRobot.runNotes(StartRobot.java:56)
at lotus.domino.NotesThread.run(NotesThread.java:215)
Can someone kindly tell me why?
hcl-bot
November 23, 2007, 6:27am
2
Subject: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
Dear xiaoming,use double back-slashes in the getDatabase method as:
getDatabase(“shc380wim01\Shanghai\americanexpress”,“myname.nsf”);
hcl-bot
November 27, 2007, 3:31am
3
Subject: RE: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
thank you for your reply.I tried this, but still get the same error…
Could you tell me what the two arguments stand for?
hcl-bot
November 21, 2007, 4:12am
4
Subject: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
Is the servername correct? Does the db exist? Shouldn’t you use back-slashes i.s.o. forwardslashes?
what happens when you write the following LS:
dim session as new NotesSession
dim targetdb as new NotesDatabase(“”, “”)
if taretdb.open(“shc380wim01/Shanghai/americanexpress”,“myname.nsf”) then
msgbox “Open ok”
else
msgbox “Open fails”
end if
hcl-bot
November 21, 2007, 10:10pm
5
Subject: RE: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
Thank u for your reply.I am writing the program in Java.
and when I use
Database mailDatabase=notesSession.getDatabase(“shc380wim01/Shanghai/citsamex”,“mail\xiaomingyan.nsf”);
mailDatabase.open();
then i will get a exception says:
Database open failed (%1)
at lotus.domino.local.Database.Nopen(Native Method)
at lotus.domino.local.Database.open(Unknown Source)
at lotusnotesrobot.StartRobot.runNotes(StartRobot.java:21)
at lotus.domino.NotesThread.run(NotesThread.java:215)
I don’t know why…
BTW, the program is running on my computer with Lotus Notes installed while the domino server is remote. I don’t know whether it matters…
Please help…
hcl-bot
November 21, 2007, 10:52pm
6
Subject: RE: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
when I print the notesSession.getServerName();it prints “”
there is nothing in the ServerName.
and when i call notesSession.getDatabase(“”,“names.nsf”);
the database is open , which means that I can open local database by the notesSession object…
but…how can i open the remote database?
Please help… Many Thanks~~
hcl-bot
November 22, 2007, 1:29am
7
Subject: RE: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
notesSession.getServerName() returns an empty string when the code is not run on a server.
hcl-bot
November 23, 2007, 12:27am
8
Subject: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
xiaoming,
You may need to use the hierarchical name for the server ie “CN=shc380wim01/OU=Shanghai/O=americanexpress”
hcl-bot
November 27, 2007, 3:31am
9
Subject: RE: Ask for help: I want to connect to local Lotus Notes to send mail but get errors
thank you for your reply.I tried this, but still get the same error…