Em_nsfnoteupdatemailbox

Hello everybody…

i have written this simple code

switch (pExRecord->EId)

{

/* Extension Manager hook EM_MAILSENDNOTE */

case EM_NSFNOTEUPDATEMAILBOX:

{

    /* check error code */

    if (pExRecord->Status != NOERROR)

	  break;



    LogLine("-------------------------------------------------\n");

    sprintf(gTextBuffer, "Calling EM_NSFNOTEUPDATEMAILBOX\n");

    LogLine( gTextBuffer );



    if (pExRecord->NotificationType == EM_BEFORE)

      sprintf(gTextBuffer, "EM_BEFORE...\n");

    else if (pExRecord->NotificationType == EM_AFTER)

      sprintf(gTextBuffer, "EM_AFTER...\n");

	LogLine(gTextBuffer);

    break;

} /* end of case */

} /* end of switch */

…but i have a problem…

in my log file i have four lines- 2 for EM_BEFORE and 2 for EM_AFTER…

can anyone tell my why?

thank you in advance

Subject: *Do you check the recursion id?

Subject: RE: *Do you check the recursion id?

i’m new in extension managers…so would you be so kind to tell me what do you mean by “checking recursion ID”?

thank you

Subject: RE: *Do you check the recursion id?

The prototype for this function is:

STATUS LNPUBLIC EMCreateRecursionID(

WORD far *retRecursionID);

Follow the EM samples provided in the C API toolkit to implement you EM program.

Subject: RE: *Do you check the recursion id?

i followed your instructions regardinf the hnote…

and i noticed thet for one pair EM_BEFORE-EM_AFTER i have the same hnote, for the other pair EM_BEFORE-EM_AFTER i have another hnote

is it possible that this EM is triggered when the note is created in mail.box and then deleted?

Subject: *Yes, it is quite possible.

Subject: RE: *Do you check the recursion id?

Possible…

In the EM_AFTER, try the following…

if (nid & RRV_DELETED)

deleted

else

not deleted

Subject: RE: *Do you check the recursion id?

here is the code…

iif(nid & RRV_DELETED)

		sprintf(gTextBuffer, "deleted\n");

	else

		sprintf(gTextBuffer, "not deleted\n");

	LogLine(gTextBuffer);

…and the log result…


Calling EM_NSFNOTEUPDATEMAILBOX

EM_BEFORE…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

hNote:8

Flags:0


Calling EM_NSFNOTEUPDATEMAILBOX

EM_AFTER…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

hNote:8

not deleted


Calling EM_NSFNOTEUPDATEMAILBOX

EM_BEFORE…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

hNote:19

Flags:8205


Calling EM_NSFNOTEUPDATEMAILBOX

EM_AFTER…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

hNote:19

not deleted

i don’t know what to do…

any ideeas?please, help me…

Subject: *Just use the one with the 0 flags.

Subject: RE: *Just use the one with the 0 flags.

and what is the meaning of 0 Flags?

Subject: EM_NSFNOTEUPDATEMAILBOX

first em is the message going into mail.box, second em is the message going out (ie actually sent/deleted).

use something like this (it’s from a sub so you probably don’t need the first two lines - i like to double check)

// check em details

if( pExRecord->EId != EM_NSFNOTEUPDATEMAILBOX ) goto Exit;

if( pExRecord->NotificationType != EM_BEFORE ) goto Exit;

if( pExRecord->Status != NOERROR ) goto Exit;



// get em parameters

ap = pExRecord->Ap;

EM_SourceNote = VARARG_GET( ap, HANDLE );

EM_UpdateFlags = VARARG_GET( ap, WORD );



// abort if update_deleted

if( UPDATE_DELETED == ( UPDATE_DELETED & EM_UpdateFlags ) ) goto Exit;

Subject: RE: EM_NSFNOTEUPDATEMAILBOX

yes, this works just fine

thank you very much

Subject: EM_NSFNOTEUPDATEMAILBOX

Hi Alexandru,

I think one set of before and after messages is for the mail.box and the other set is for the mail database being updated.

You can can the database handle and filename from the nHandle to verify the databases associated with the EM_NSFNOTEUPDATEMAILBOX message.

NSFNoteGetInfo(nHandle, _NOTE_DB, &dbHandle);

sStauts = NSFDbReopen(dbHandle, &dbHandlex);

sStatus = NSFDbPathGet(dbHandlex, szCanonical, szExpanded);

NSFDbClose(dbHandlex);

Let me know your results.

Regards,

James Greene

Jagre Incorporated

www.jagre.net

Subject: RE: EM_NSFNOTEUPDATEMAILBOX

here is the new result…

Calling EM_NSFNOTEUPDATEMAILBOX

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

the second EM_BEFORE is identical…

any ideeas?

Subject: RE: EM_NSFNOTEUPDATEMAILBOX

Hmmm…

Try aquiring the NOTE ID in the EM_AFTER to see what value is returned.

NSFNoteGetInfo(nHandle, _NOTE_ID, &nid);

Subject: RE: EM_NSFNOTEUPDATEMAILBOX

here is the new log…-------------------------------------------------

Calling EM_NSFNOTEUPDATEMAILBOX

EM_BEFORE…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box


Calling EM_NSFNOTEUPDATEMAILBOX

EM_AFTER…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box


Calling EM_NSFNOTEUPDATEMAILBOX

EM_BEFORE…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box


Calling EM_NSFNOTEUPDATEMAILBOX

EM_AFTER…

Canonical path: mail.box

Expanded path: C:\Lotus\Domino\Data\mail.box

and here is the new code…

switch (pExRecord->EId)

{

/* Extension Manager hook EM_MAILSENDNOTE */

case EM_NSFNOTEUPDATEMAILBOX:

{

	

	ap = pExRecord->Ap;

    hNote = VARARG_GET (ap, NOTEHANDLE);



    /* check error code */

    if (pExRecord->Status != NOERROR)

	  break;



    LogLine("-------------------------------------------------\n");

    sprintf(gTextBuffer, "Calling EM_NSFNOTEUPDATEMAILBOX\n");

    LogLine( gTextBuffer );



	if (pExRecord->NotificationType == EM_BEFORE){

      sprintf(gTextBuffer, "EM_BEFORE...\n");

	  LogLine(gTextBuffer);

	  NSFNoteGetInfo(hNote, _NOTE_DB, &hDB);

	  if (NSFDbPathGet(hDB,retCpath,retEpath))

		  break;

	  sprintf(gTextBuffer, "Canonical path: %s\n", retCpath);

	  LogLine(gTextBuffer);

	  sprintf(gTextBuffer, "Expanded path: %s\n", retEpath);

	  LogLine(gTextBuffer);

	}

    else if (pExRecord->NotificationType == EM_AFTER)

	{sprintf(gTextBuffer, "EM_AFTER...\n");

	  LogLine(gTextBuffer);

	  NSFNoteGetInfo(hNote, _NOTE_DB, &hDB);

	  if (NSFDbPathGet(hDB,retCpath,retEpath))

		  break;

	  sprintf(gTextBuffer, "Canonical path: %s\n", retCpath);

	  LogLine(gTextBuffer);

	  sprintf(gTextBuffer, "Expanded path: %s\n", retEpath);

	  LogLine(gTextBuffer);



	}

    break;

} /* end of case */

} /* end of switch */

would you like to see all coding?