Ask for help: I want to connect to local Lotus Notes to send mail but get errors

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?

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”);

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?

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

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…

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~~

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.

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”

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…