Link to home
Start Free TrialLog in
Avatar of jlalande
jlalande

asked on

How are arguments passed to NSSession.GetCalendar and NSSession.GetDatabase in the Notes C++ SDK?

I have configured Lotus Notes with the server 'alpha-romeo/dev' and my administrator has informed me that my user file on the Domino server is jlalande.nsf.  Therefore, my code to retrieve the Notes calendar is:

LNSTATUS status = session.GetCalendar(&calendar, "alpha-romeo/dev", "jlalande.nsf", "jlalande");

The documentation indicates that I have to open the database before retrieving calendar items, which I do with:

LNDatebase db;
status = session.GetDatabase("jlalande.nsf", &db, "alpha-romeo/dev");
status = db.Open();

However, db.Open fails with the message "File does not exist".

I suspect my parameters are not correct.
Avatar of mbonaci
mbonaci
Flag of Croatia image

Where does it say you have to open the db first?
Here's an example from C++ API, Schedule:
//===========================================================================
//
//
//	Program:    Schedule
//
//	File:       SCHEDULE.CPP
//
//	Syntax:     SCHEDULE <filename> <ownername> <start date> <end date> <server>
		
//				A sample command line for schedule is:
//	schedule jdoe.nsf "Jane Doe" "07/08/98 9:00am" "07/08/98 10:00am" "Saturn"
//	(The date syntax is mm/dd/yy)
//
//	Description:
//				This program shows how to use the calendaring and scheduling 
//				features.
//
//  Note: 		This sample could take a minute or more to run if you have a 
//				large number of entries in your calendar.
//
//===========================================================================

#include <iostream>

#include <lncppapi.h>
#include <lncalend.hpp>

#define ERR_BUF_SIZE 512

using namespace std;

char CommandBuf[80];

int main(int argc, char *argv[])
{
	char *			File;
	char *			User;
	char *			Server=NULL;
	char *			Start;
	char *			End;
	LNNotesSession	Session;
	LNCalendar		Calendar;
	LNCalendarEntry	Entry;

	// Check the command line.
	if (argc < 6) 
	{
		cout << "\nUsage:\n\t" << argv[0]
			<< " <filename> <username> <startdate> <enddate> <server> \n"
			<< endl;
		return(1); 
	}

	// Get info from command line.
	File = argv[1];
	User = argv[2];
	Start = argv[3];
	End = argv[4];
	Server = argv[5];

	// Set the error handler to throw all errors encountered during execution.
	LNSetThrowAllErrors(TRUE);

	try
	{
		LNDatetimeRange TheDate;
		LNText 			List;
		LNString 		DateString;
		LNString 		Desc;

		// Initialize the C++ API.
		Session.Init(argc, argv);

		// These must be done AFTER the session is initialized
		LNDatetime 		AptBegin ( Start );
		LNDatetime 		AptEnd (  End ) ;
	
		TheDate.SetBegin(AptBegin);
		TheDate.SetEnd(AptEnd);

		// Get a calendar
		Session.GetCalendar(&Calendar, Server, File, User);	

		cout << "Searching the file '" << File <<  "' on server '" << Server << "'..." << endl;

		// Check if a certain date is available
		if (Calendar.IsAvailable(TheDate))
		{
			// Create an appointment type entry for this date
			Calendar.CreateEntry(TheDate, "My appointment", LNCALENTRYTYPE_APPOINTMENT, &Entry);

			// Get the brief description and display it
			Desc = Entry.GetBriefDescription();
			cout << "The description that was set was: " << Desc << endl;

			// Get the date information and display it
			TheDate = Entry.GetDatetimeRange();
			TheDate.GetText(&DateString);
			cout << "The date that was set was: " << DateString << endl;
		
			// Save the entry
			Entry.Save();
		}
		else
			cout << "The date that you requested is not available" << endl;


	}

	// Error handler.  If an error occurred then get the text of
	// the error message and display it.
	catch (LNSTATUS lnerror)
	{
		char ErrorBuf[ERR_BUF_SIZE];
		LNGetErrorMessage(lnerror, ErrorBuf, ERR_BUF_SIZE);
		cout << "Error:  " << ErrorBuf << endl;
	}

	cout << "All Done.  Hit return to exit: ";
	cin.getline(CommandBuf, 50);
	

	// Terminate the API.
	Session.Term();

	return (0);
}



Param rules:
LNSTATUS GetCalendar(LNCalendar *calendar, const  LNString &server = "", const LNString &dbname="", const LNString &ownername="")

calendar
    Output, pointer to object representing calendar.

server
    Optional input, reference to object representing name of server to search. If omitted or null, the local machine is searched.

dbname
    Optional input, reference to object representing name of mail database to use. If omitted or null, the user's mail file is used. The specified database is opened.

ownername
    Optional input, reference to object representing name of user. Depending on the setup of your Notes environment, you may need to specify a fully-qualified (hierarchical) name (for example, "John Smith/BOS/SmithCo"). If omitted or null, the current user is assumed.

Open in new window

Avatar of jlalande
jlalande

ASKER

mbonaci:

I am double checking with the Domino administrator as to whether the file mentioned in my question 'jlalande.nsf' is actually the mail file listed in the server's names.nsf file.

I appreciate the links you've sent, but they mostly address the creation of calendar entries and I only need to read the existing entries.  Or was there something in particular in those that you thought could help me?

Thanks!
You can also check the name and path of your mail file in your Office(Online) location document.
Local address book > Advanced > Locations
Mail tab > fields "Mail file location" & "Mail file"
mbonaci:

I am using 8.5.1 FP2 and I don't see this option at all.
ASKER CERTIFIED SOLUTION
Avatar of mbonaci
mbonaci
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is it.  Thanks!