Got "Member not found" when our app call GETENVIRONMENTSTRING

We developed a piece of VC++ 6.0 application using the Notes32 OLE wrapper class to create email(s) in Lotus Notes client(8.5.1). The LN client connects to a Domino server(not sure the release version).

We run into a problem where it sometimes creates the email without problem but sometimes not. It usually throws “member not found” or “The object invoked has disconnected from its client”. It is always able to create the NOTESSESSION object with CreateDispatch(), but for some reason, it then throws the exceptions when it calls GETENVIRONMENTSTRING or GETDATABASE in my GetMailDatabase() method.

This issue is intermittent. In some occassions, we may have multiple exe of this app running at the same time. It may create 1 or two emais but not the others. We have thought about

  1. the possiblity of resource conflict, i.e. LN session, b/w exes, but then it also fails when there is only single exe running.

  2. not enough permission. Users are required to login when they launch the lotus notes client. But then, our app can generate some emails without providing the password. In addition, NOTESSESSION doesn’t have method that takes the password(HASHPASSOWRD() and VERIFYPASSWORD() don’t count). Furthermore, GETENVIRONMENTSTRING operation shouldn’t need a connection to the mail DB, right?

I have tried many different code and google

search, but still have no success. I pretty much run out of idea. Would very appreciated if anyone can provide some pointers…my code? Lotus notes settings? server setting? tools in LN to troubleshoot?

Here is my code :-

NOTESSESSION *CLNAutomater::GetSession()

{

NOTESSESSION *lpnsession = new NOTESSESSION;

COleException e;

// get a session

if ( !lpnsession->CreateDispatch(“Notes.NotesSession”, &e) ) {

  if ( !lpnsession->CreateDispatch("Lotus.NotesSession", &e) ) {

     ReportException(&e, _T("Unable to open user session"));

 return NULL;

  }

}

return lpnsession;

}

NOTESDATABASE CLNAutomater::GetMailDatabase(NOTESSESSION *lpnsession)

{

// open the user’s mail database

NOTESDATABASE ndb;

ndb.m_lpDispatch = NULL;

TRY {

  COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

  CString cstrMailFile = lpnsession->GETENVIRONMENTSTRING("MailFile", COV_TRUE);



  CString cstrServer = "";

  CString cstrMailType = lpnsession->GETENVIRONMENTSTRING("MailType", COV_TRUE);

  cstrMailType.TrimLeft();  

  cstrMailType.TrimRight();

  if (cstrMailType != "1") 	//0-Server	1-Local

     cstrServer = lpnsession->GETENVIRONMENTSTRING("MailServer", COV_TRUE);

	

  COleVariant cvar = lpnsession->GETDATABASE(cstrServer, cstrMailFile, covOptional);

  if ( cvar.vt == VT_EMPTY ) {

     m_csLastError.Format("Error opening database \"%s\".", cstrMailFile);

 return NULL;

  }

  ndb = cvar.pdispVal;

  ReleaseVariant(cvar);

}

CATCH_ALL(e) {

  //I have checked the m_lpnsession variable at this point and it is not NULL!

  ReportException(e, _T("Error retrieving mail database"));

}

END_CATCH_ALL

return ndb;

}

BOOL CLNAutomater::InitSession()

{

if ( m_lpnsession != NULL )

  return TRUE;

// get the session

m_lpnsession = GetSession();

if ( m_lpnsession == NULL )

  return FALSE;

m_ndb = GetMailDatabase(m_lpnsession);

if ( m_ndb.m_lpDispatch == NULL )

  return FALSE;

// get the user’s workspace

m_lpnuiws = GetWorkspace();

if ( m_lpnuiws == NULL )

  return FALSE;

return TRUE;

}

void CLNAutomater::CreateMyEmail() {

m_lpnsession = NULL;

InitSession()

}

~Thank you.