Hi Everyone, Please help!
I have written a EM dll to catch the EM_MAILSENDNOTE(EM_BEFORE) event, and want to insert some text to the mail
content. When I debug this dll, I found all calling of C API is successfully. But I cannot find the text in the mail of
recipients. I wrote to code as extmail example, I did not know why it not work. Could any one help?
My code is :
case EM_MAILSENDNOTE:
{
HANDLE hNote = NULL;
VARARG_PTR ap;
char AppendLine[1024];
HANDLE far hBody = NULL;
DWORD far dwBodyLen;
WORD Len;
/* get the arguments */
ap = pExRecord->Ap;
hNote = VARARG_GET (ap, HANDLE);
if (!hNote)
return(ERR_EM_CONTINUE);
/* check error code */
if (pExRecord->Status != NOERROR)
break;
if (pExRecord->NotificationType == EM_BEFORE)
{
sError = MailGetMessageBody(hNote,&hBody,&dwBodyLen);
if (!hBody)
sError = MailCreateBodyItem(&hBody, &dwBodyLen);
strcpy(AppendLine, "*** Insert Text in the mail! ***");
Len = strlen(AppendLine);
sError = MailAppendBodyItemLine(hBody, &dwBodyLen, AppendLine, Len);
sError = MailAddBodyItem(hNote, hBody, dwBodyLen, NULL);
}
}
Subject: Why I cannot modify the mail content when EM_MAILSENDNOTE?(by C API)
A few different questions/comments.
First, it may be called successfully, but is it actually invoking the code? Put in some AddInLogMessage calls to see what is happening.
Second, do you realize that if this works, it will destroy all formatting and leave a plain-text message (no graphics, no font attributes, no tables, nothing left), and that the message must be no more than 64KB long? The MailGetMessageBody has the following comment in the C AP (emphasis added by me)I:
This function returns a copy of the text of the Body field from an open message.
The Body field is converted to a series of 78 or less character lines. Each line is terminated by a null character (‘\0’).
This function can only handle plain text and can only return the text when it is 64 KB or less. See the MailGetMessageBodyText function for handling text greater than 64KB.
Third, the MailAddBodyItem seems to suggest that you can only do this with messages that were created by MailCreateBodyItem.
Use this function with a text-only body item created by MailCreateBodyItem and initialized by MailAppendBodyItemLine.
I hope these comments help.
Subject: Thanks Ben
Hi Ben, Thanks very much!
I have done some research on it. I found:
1) Although we only type text of a memo body in Notes client, in the EM_MAILSENDNOTE event, the message
body item will be a Richtext item not TEXT item.
2) When send Internet mail, the EM_MAILSENDNOTE event will be called twice. Because if there is a form(or
other Notes element) in the mail, Notes will change them to common text or attach file.
3) We can use NSFxxx API to query, modify and delete any item in the message. I have tested it, no I can
modify the mail by this way.
Thank you, Ben. Let's help each other. I want to be your friend.
My Internet mail address: eddy_zan@hotmail.com
Regards,
~Eddy