Creating new documents in Calendar using C++ toolkit

Hi there,

I am trying to build a program using the c++ toolkit. basically the program is suppose to be able to add/delete calendar appointments/meetings records from my mail database wtanctls.nsf.

Currently i have managed to create a new document. However, when i check the Lotus Notes UI, although the new contact is showing, the following errors always show when i try to double click the entry to view the document.

“error trying to open document: Note item not found”

Is there anyone who knows what the error is? Is it something i have missed out?

Thanks a million in advance. I have been troubled by this problem for days and will be very grateful to anyone that can help in anyway. Thanks once again.

Posted below is my sample program.

void CLotusTestCalendar2Dlg::OnAddnew()

{

LNNotesSession	CreateDocSession;

LNDatabase ToDoDB;

LNDocument NewDoc;

LNViewFolder view;

LNText SubjectText,ImptText;

LNText FromText;

LNINT i=0, count = 0; 

LNText NewDocText;

LNDocumentArray DocArray;

LNVFEntry entry;  

LNString LnstrDocText;

LNDatetimes EntryDocDatetimes,EndDateTimes;

LNDatetime EntryDocDatetime,EndDateTime;



LNNumbers IconNumber;



CreateDocSession.Init();



CreateDocSession.GetDatabase("C:\\Program Files\\lotus\\notes\\data\\mail\\wtanctls.nsf", &ToDoDB);



ToDoDB.Open();



	

ToDoDB.GetViewFolder("Calendar", &view);



view.Open();





if(ToDoDB.CreateDocument(&NewDoc)==0)

	MessageBox("Document created");



NewDoc.SetForm("Appointment");	



SubjectText.SetValue("Watch Movie");

NewDoc.CreateItem("Subject",SubjectText,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();



SubjectText.SetValue("0");//0 is appointment, 3 is meeting

NewDoc.CreateItem("AppointmentType",SubjectText,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();



SubjectText.SetValue("Z=8$DO=1$DL=4 1 1 10 -1 1$ZX=51$ZN=Pacific");

NewDoc.CreateItem("StartTimeZone",SubjectText,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();



SubjectText.SetValue("stdNotesLtr0");

NewDoc.CreateItem("Logo",SubjectText,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();



IconNumber.SetValue(160);

NewDoc.CreateItem("_ViewIcon",IconNumber,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();



EntryDocDatetime.SetDate(02,18,2005);

EntryDocDatetime.SetTime(3,33);

EntryDocDatetimes.SetValue(EntryDocDatetime);

NewDoc.CreateItem("STARTDATETIME",EntryDocDatetimes,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();	



EndDateTime.SetDate(02,18,2005);

EndDateTime.SetTime(3,33);

EndDateTimes.SetValue(EndDateTime);

NewDoc.CreateItem("ENDDATETIME",EndDateTimes,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();		



EntryDocDatetimes.SetValue(EntryDocDatetime);

NewDoc.CreateItem("CalendarDateTime",EntryDocDatetimes,LNITEMFLAGS_SUMMARY, LNITEMOPTION_DELETE_APPEND);//,LNITEMFLAGS_SUMMARY);

NewDoc.Save();	



//view.FolderAddDocument(NewDoc);//This will not work as 'ToDo' is not a folder but a view.





NewDoc.Close();



view.Close();



ToDoDB.Close();



CreateDocSession.Term();	

}

Subject: Database name for the calendar.

Hello, Can I know the database name for the calendar. As we store the contacts in names.nsf in Lotus Notes, under what name, the appointments,meetings,anniversaries are all stored in the calendar of Lotus Notes. I searched a lot of nsf files in my system, but could not get where the appointemnts,meetings are all stored. Please help me in this regard and thans a lot in advance.

Subject: About displaying the added appointments on the Lotus Notes Calendar.

Hello Weelip, I am writing a program in Lotus C to add appointments to the Lotus Notes Calendar. They are getting added but they are not getting displayed properly Lotus Notes Calendar, when I open it. But, when I search for a string which is usually the data in the appointment, I can view the added appointments.

Also if I try to open the added appointments, I am getting the problem

“error trying to open document: Note item not found”

the same one, which you are facing. You told to add the Chair field, on which you got solved that problem. I added the chair field also, but still I am unable to view the added appointments, once I open the Lotus Notes Calendar after adding the appointments.

My code is as follows:

#include <stdio.h>

#include <stdlib.h> // _itoa

#include <global.h>

#include <nsfdb.h> // NSFDbOpen

#include <nsfsearc.h> // NSFSearch

#include <nsfnote.h> // NSFNoteOpen

#include <osmem.h> // OSMemFree

#include <nif.h> //For NIFFindView

#include <nsfdata.h> //For NSF Data

#include <osmisc.h> //For OSLoadString

#include <textlist.h>

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <sys/stat.h>

#include <sys/types.h>

/*Notes API Headers */

#include <lapicinc.h>

#include <lapiplat.h>

#include <stdnames.h>

#include <osmem.h>

#include <osfile.h>

#include <design.h>

#include <foldman.h>

#include <idtable.h>

DBHANDLE hdb;

/* ascii compile */

#if defined(OS390) && (STRING_CODE_SET==ISO8859-1)

#include <_Ascii_a.h> /* NOTE: must be the LAST file included */

#endif /* OS390, ascii compile */

/* define exit codes if they are not defined elsewhere */

#ifndef EXIT_SUCCESS

#define EXIT_SUCCESS 0

#endif

#ifndef EXIT_FAILURE

#define EXIT_FAILURE 1

#endif

/* Local function prototypes */

void print_api_error (STATUS);

char *StripBlanks(char *InputString);

STATUS AddANote(DBHANDLE hdb);

STATUS LNPUBLIC DeleteNotes(VOID *db_handle,

SEARCH_MATCH *search_info,

ITEM_TABLE *summary_info);

STATUS NOTESAPI SearchProc(void* Param,

						 SEARCH_MATCH* pSM,

						 ITEM_TABLE* SummaryBuffer);

#define ServerName “Local” /* Name of the Notes Server */

#define FormName MAIL_APPOINTMENT_FORM /* Name of the Note Document */

#define Type MAIL_APPOINTMENT_FORM /Name of the Type value/

#define RecordLength 241 /* Length of the record to be read */

int main (int argc, char *argv)

{

/* Local data declarations */

char *path_name; /* pathname of database */

// char *db_name=“C:\Program Files\lotus\notes\data\names.nsf”;

// char *db_name = “C:\Program Files\lotus\notes\data\busytime.nsf”;

char *db_name = "C:\\Program Files\\lotus\\notes\\data\\mail\\nityha.nsf";

char fullpath_name[101]; /* Full pathname of database */

char buffer[NSF_INFO_SIZE];/* database info buffer */

char title[NSF_INFO_SIZE]; /* database title */

STATUS error; /* error code from API calls */

DBHANDLE db_handle; /* open handle to sample db */

NOTEHANDLE note_handle; /* note handle */

FILE *FilePtr; /* Pointer to the open file */

char FileDataBuffer[300]; /* Input record buffer */

WORD wLength;

char DataDir[256];

char pathfile_name[560];

char *viewname = "($calendar)";

HCOLLECTION collhandle=NULL;

HANDLE bufferhandle;

DWORD count;

WORD flg;

COLLECTIONPOSITION collpos;

DWORD matches;

NOTEID	viewid;

NOTEID pNoteID;

NOTEID main_nid;

BOOL found;

char *itemname=" ";

STATUS ret=NULL;

WORD wbuild;

// char InputFile[85];

#if defined(OS390)

char LMBCSArg[MAXPATH]; /* translation buffer */

#endif /* OS390 */



/* Get the pathname of the database from the command line. */

if (argc != 2)

{

	/* ascii compile */

	#if defined(OS390) && (__STRING_CODE_SET__==ISO8859-1)

	OSNativeToLMBCS(argv[0], MAXWORD, LMBCSArg, MAXPATH);

	printf( ²\nUsage: %s <database filename>\n² , LMBCSArg);

	#else

	printf( "\nUsage: %s <database filename>\n" , argv[0] );

	#endif /* OS390, ascii compile */

}



#if defined(OS390)

OSNativeToLMBCS(argv[1], MAXWORD, LMBCSArg, MAXPATH);

path_name = LMBCSArg;

#else

path_name = argv[1];

#endif /* OS390 */



/* Start a notes connection */

error = NotesInitExtended (argc, argv);

if (error)

{

	printf("\nError initializing Notes\n" ) ;

	exit (EXIT_FAILURE);

}

else

{

	printf("\nThe notes is initialized\n");

}



wLength = OSGetDataDirectory(DataDir);

if(wLength > 0)

	printf("\nThe length of data directory is %s\n\n\n", DataDir);



/* Open the database. */

if (error = NSFDbOpen (db_name, &hdb))

{

	printf("\nUnable to open the database\n");

	//print_api_error (error);

	NotesTerm();

	return(error);

}

else

{

	printf("\nThe database is opened\n");

}





/* Get the database title. */

if (error = NSFDbInfoGet (hdb, buffer))

{

	NSFDbClose (hdb);

	NotesTerm();

	exit (EXIT_FAILURE);

}



/* Get the title from returned buffer */

NSFDbInfoParse (buffer, INFOPARSE_TITLE, title, NSF_INFO_SIZE - 1);



if (error = NSFDbGetBuildVersion(hdb, &wbuild)) 

{

	printf("\nUnable to get Lotus Notes version:\n");

	NSFDbClose(db_handle);

	NotesTerm();

	return(error);

}



/* Print the title. */

#if defined(OS390) && (__STRING_CODE_SET__!=ISO8859-1)

OSLMBCSToNative(title, MAXWORD, LMBCSArg, sizeof(LMBCSArg));

printf (²\n #1 Create a Form in this database:(%s)(%s)\n² ,

path_name,LMBCSArg);

#else

// printf (“\n Create a Form in this database:(%s)(%s)\n” ,path_name,title);

printf ("\nCreate a Form in this database:(%s)(%s)\n" ,NULL,title);

#endif /* OS390, ebcdic compile */

/* if (error = NSFSearch

(hdb, // database handle 

NULL, // selection formula (all) 

NULL, // title of view in selection formula 

0, // search flags 

NOTE_CLASS_DATA,// note class to find 

NULL, // starting date (unused) 

DeleteNotes, // action routine for notes found 

&hdb, // argument to action routine 

NULL)) // returned ending date (unused) 

{

	NSFDbClose (hdb);

}



NSFDbClose (hdb);*/



	//Start Loop and read all records in the file 

// if (error = AddANote(FileDataBuffer,hdb))

if (error = AddANote(hdb))

{

	//print_api_error (error);

	// Close the database. 

	if (hdb)

	{

		if (error = NSFDbClose (hdb))

		{

			//print_api_error (error);

			NotesTerm();

			exit (EXIT_FAILURE);					

		}

	}

}	



TCHAR *strFormula = "SELECT Form = \"Appointment\" ";



int len = strlen(strFormula);



FORMULAHANDLE  hFormula;

WORD wLen = 0;

WORD wd = 0;

//	Compile the Formula

ret = NSFFormulaCompile(NULL, 0, 

						(TCHAR*)(LPCSTR)strFormula,len, 

						&hFormula, 

						&wLen, &wd, &wd, &wd, &wd, &wd);





NSFDbClose (hdb);



/* Terminate Notes. */

// NotesTerm();

/* End of main program. */

exit (EXIT_SUCCESS);

}

/* ===================================================== */

/* This function prints the API error message associated */

/* with an Lotus Notes C API error code. */

/* ===================================================== */

void print_api_error (STATUS api_error)

{

STATUS string_id = ERR(api_error);

char error_text[200];

WORD text_len;

/* Get the message for this API error code from */

/* the resource string table. */

text_len = OSLoadString (

NULLHANDLE,

string_id,

error_text,

sizeof(error_text));

/* Display the message. */

/* ebcdic compile */

#if defined(OS390) && (__STRING_CODE_SET__!=ISO8859-1)

OSLMBCSToNative(error_text, MAXWORD, error_text, sizeof(error_text));

#endif /* OS390, ebcdic compile */

fprintf (stderr, "\n%s\n",  error_text);

}

/**********************************************************************/

/* */

/* FUNCTION: AddANote */

/* */

/* PURPOSE: Local function called by the main to create a new */

/* notes document in a database. */

/* */

/**********************************************************************/

STATUS AddANote(DBHANDLE db_handle)

{

/* Local data declarations. */

STATUS error = NOERROR; /* return code from API calls */

TIMEDATE timedate; /* contents of a time/date field */

double TempDouble;

double NotesDouble;

double ZeroDouble; /* JAM doubleword zero constant */

char TempStr[101]; /* Null Term item text string */

char TempFullName[101]; /* Null Term item text string */

NOTEID viewid;

NOTEID FormNoteId=NULL;

HANDLE IDTable_handle=NULL;

NOTEID FNoteID;

NOTEHANDLE note_handle=NULL; /* note handle */

STATUS ret=NULL;

HANDLE hIDTable=NULL;

NOTEID pNoteID=NULL;

NOTEID main_nid;

//NOTEID Doc_ID;

TempDouble = 0;

ZeroDouble = 0; /* JAM */

char *viewname="($calendar)";



/* Create a new data note. */	

/* if (error = NSFNoteCreate (db_handle, &note_handle))

return (error);*/

HCOLLECTION collhandle; 

COLLECTIONPOSITION collpos;





if(error=NSFNoteCreate(hdb,&note_handle))

{

	printf("\nUnable to create the note\n");

	NSFDbClose(hdb);

	NotesTerm();

	return(error);

}

else

{

	printf("\nThe note has been created\n");

}



NSFNoteGetInfo(note_handle,pNoteID,&main_nid);

	



//Write the form name to the note. 

if (error = NSFItemSetText (note_handle, FIELD_FORM,  FormName, MAXWORD))

{

	printf("\nUnable to set the form value\n");

	NSFNoteClose (note_handle);

	NotesTerm();

	return (error);

}

else

{

	printf("\nThe formvalue has been set\n");

}





if(error=NSFItemSetText(note_handle,FIELD_TYPE_TYPE,Type,MAXWORD))

{

	printf("\nUnable to set the field type\n");

	NSFNoteClose(note_handle);

	NotesTerm();

	return(error);

}

else

{

	printf("\nThe type value has been set\n");

}



if (error = NSFNoteUpdate (note_handle, 0))

{

	printf("\nUnable to save the note:\n");

    NSFNoteClose (note_handle);

	NSFDbClose(db_handle);

    return(error);

}

else

{

	printf("\nThe form has been updated\n");

}



//	Something to make the console output look readable

printf("\n");

printf("Start Date\tStart Time\tEnd Date\tEnd Time\tCalendar Date Time\tSubject\n");



printf("\nThe formname and type for calendar has been set\n");





printf("\nThe document has been created\n");





if(error = FolderCreate(hdb,NULLHANDLE,0L,NULLHANDLE,FOLDER_CALENDAR,

	(WORD)strlen(FOLDER_CALENDAR),DESIGN_TYPE_SHARED,0L,&FNoteID));



printf("\nThe folder calendar has been created\n"); 





memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Chair Holder of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s" , TempStr);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"Chair", TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"Chair",(WORD)strlen("Chair"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);

}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Subject of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s" , TempStr);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"Subject", TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"Subject",(WORD)strlen("Subject"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the AppointmentType of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s" , TempStr);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"AppointmentType", TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"AppointmentType",(WORD)strlen("AppointmentType"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the StartTimeZone of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s" , TempStr);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"StartTimeZone", TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"StartTimeZone",(WORD)strlen("StartTimeZone"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}





memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Start Date of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s" , TempStr);



// Set the Office Field in the note. 

if (error = NSFItemSetText(note_handle,MAIL_CS_STARTDATE_ITEM, TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,MAIL_CS_STARTDATE_ITEM,(WORD)strlen(MAIL_CS_STARTDATE_ITEM),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Start Time of the contact\n");

scanf("\n%s",TempStr);

sprintf(TempFullName,"%s, %s" , TempFullName,TempStr);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"StartDateTime" , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"StartDateTime",(WORD)strlen("StartDateTime"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the End Date of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



// Set the Office Field in the note. 

if (error = NSFItemSetText(note_handle,MAIL_CS_ENDDATE_ITEM	 , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,MAIL_CS_ENDDATE_ITEM	,(WORD)strlen(MAIL_CS_ENDDATE_ITEM	),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the End Time of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,"EndDateTime"	 , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,"EndDateTime"	,(WORD)strlen("EndDateTime"),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Calendar Date Time of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



// Set the Office Field in the note. 

if (error = NSFItemSetText(note_handle,MAIL_CS_CALENDARDATETIME_ITEM	 , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,MAIL_CS_CALENDARDATETIME_ITEM	,(WORD)strlen(MAIL_CS_CALENDARDATETIME_ITEM),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Location of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,MAIL_LOCATION_ITEM	 , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,MAIL_LOCATION_ITEM,(WORD)strlen(MAIL_LOCATION_ITEM),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Categories of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,CATALOG_ITEM_META_CATEGORIES , TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,CATALOG_ITEM_META_CATEGORIES,(WORD)strlen(CATALOG_ITEM_META_CATEGORIES),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}



memset(&(TempStr[0]),'\0' , sizeof(TempStr));

printf("\nEnter the Description of the contact\n");

scanf("\n%s",TempStr);	

sprintf(TempFullName,"%s %c" , TempFullName,TempStr[0]);



/* Set the Office Field in the note. */

if (error = NSFItemSetText(note_handle,MAIL_DESCRIPTION_ITEM, TempStr,MAXWORD))

{

	NSFNoteClose (note_handle);

	return (error);

}



if(error = NSFItemAppend(note_handle,NULL,MAIL_DESCRIPTION_ITEM,(WORD)strlen(MAIL_DESCRIPTION_ITEM),TYPE_TEXT,TempStr,(DWORD)strlen(TempStr)))

{

	NSFNoteClose (note_handle);

	return (error);



}

/* To add documents to this folder, create an id table of docs */

if (error = IDCreateTable(sizeof(NOTEID), &hIDTable))

{

	printf("\nError creating ID table:");

	NSFDbClose (hdb);

	NotesTerm();

	return(error);

}



if (error = IDInsert(hIDTable,main_nid, NULL))

{



	OSUnlockObject(hIDTable);

	OSMemFree (hIDTable);

	IDDestroyTable(hIDTable);

	printf("\nError saving note to ID table\n");

	NSFDbClose (db_handle);

	NotesTerm();

	return(error);

 }

else

{

	printf("\nThe tabel is inserted \n");

}



// Add the note to the database. 

if (error = NSFNoteUpdate (note_handle, 0))

{

	NSFNoteClose (note_handle);

	return (error);

}

else

{

	printf("\nThe note has been updated\n");

}

// NSFDbClose(hdb);

return (error);

}

/**********************************************************************/

/* */

/* FUNCTION: DeleteNotes */

/* */

/* PURPOSE: Local function that will delete a notes document. */

/* This function will be called for each document that was */

/* found with the notes search function (NSFsearch). */

/* */

/**********************************************************************/

STATUS LNPUBLIC DeleteNotes(VOID *hdb,

						SEARCH_MATCH *search_info,

						ITEM_TABLE *summary_info)

{

//Local data declarations. 

STATUS error;

SEARCH_MATCH SearchMatch; // local copy of search match 

memcpy ((char*)(&SearchMatch),(char *)search_info,

sizeof(SEARCH_MATCH));

if (error = NSFNoteDelete(*(DBHANDLE*)hdb,

										SearchMatch.ID.NoteID,0))

	return (ERR(error));

return (NOERROR);

}

/**********************************************************************/

/* */

/* FUNCTION: StripBlanks */

/* */

/* PURPOSE: Local function that will remove all blank from the */

/* end of a string. This function will be called from */

/* the AddANote function. */

/* */

/**********************************************************************/

char *StripBlanks(char *InputString)

{

char OutputString[201];

int I,O;

memset(&(OutputString[0]),'\0', sizeof(OutputString));

O = 0;

for(I=0;I<strlen(InputString);I++)

{

	if((InputString[I]=' ') || (InputString[I+1]='  '))

	OutputString[O] = '\0';

	else

	OutputString[O]=InputString[I];

	O = O + 1;

}

return(&(OutputString[0]));

}

/**********************************************************************/

/* */

/* FUNCTION: APIErrHandler */

/* */

/* PURPOSE: Local function that will indicate the error */

/**********************************************************************/

void APIErrHandler (STATUS error)

{

STATUS  errorid = ERR(error);

char    errorstring[200];

WORD    len;



len = OSLoadString (NULLHANDLE,

                         errorid,

                         errorstring,

                         sizeof(errorstring));





printf ("Encountered this error : %s", errorstring);

}

STATUS NOTESAPI SearchProc(void* Param,

						 SEARCH_MATCH* pSM,

						 ITEM_TABLE* SummaryBuffer)

{

if (pSM->SERetFlags != SE_FMATCH) 

	return NOERROR;



NOTEHANDLE hNote;

NUMBER number_field;

// double num;

// char number_field[560];

STATUS error;

char field_text[500];

NUMBER  pReqNumber;

NOTEHANDLE hSecondNote;

STATUS ret=NULL;

// char str1[500] = “amoghg”;

NSFNoteOpen(hdb, pSM->ID.NoteID, 0, &hNote);

if (hNote)

{

	TCHAR str[1000];

	TCHAR str1[1000];

	TCHAR strDocument[5112];

	char field_text[500];

	char field_text1[500];



//	printf("the email is %d\n",str1);

	

	ZeroMemory(strDocument,sizeof(strDocument));

	NSFItemGetText(hNote, "StartDate",str, 560);

	strcat(strDocument,str);



	NSFItemGetText(hNote, "StartTime",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "EndDate",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "EndTime",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "CalendarDateTime",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "Location",str, 560);

	strcat(strDocument,"\t\t\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "Categories",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);



	NSFItemGetText(hNote, "Description",str, 560);

	strcat(strDocument,"\t");

	strcat(strDocument,str);





	if(strcmp(str,"") || strcmp(str1,""))

	printf("%s\n",strDocument);



	NSFNoteClose(hNote);





}

return NOERROR;

}

Can you please tell me where I am doing the mistake or any thing needs to be added more to my program to make the appointments get displayed.

Please do guide me in this regard and thanks a lot in response.

Subject: Creating new documents in Calendar using C++ toolkit.

have seen this error reported for calender entries that have been imported by outlook.

i’m not shure, but that’s probably caused by mailbox scriptclasses - maybe you have a chance to debug it, where this error is raised.

next step: use notespeek to get a look on this document and compare it to a similar created in notes - what’s the difference - are you missing some items?

have you check c-api user guide? it contains some documentation about what cal-events consist of?

why don’t you use c++ classes like LNCalender? maybe they don’t supply your needs?

Markus Seitz

markus.seitz@icodex.com

Subject: RE: Creating new documents in Calendar using C++ toolkit.

Thanks Markus for your reply. Apparently i have missed out one field - the chair field. The program works now. Thanks.