Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lotus notes 如何在lotus notes(C API)中向邮件正文追加文本_Lotus Notes_Lotus Domino - Fatal编程技术网

Lotus notes 如何在lotus notes(C API)中向邮件正文追加文本

Lotus notes 如何在lotus notes(C API)中向邮件正文追加文本,lotus-notes,lotus-domino,Lotus Notes,Lotus Domino,我一直在尝试将一些文本附加到LotusNotes客户端发送的邮件中。为此,我已在活动前向EM_REG_注册了EM_MAILSENDNOTE。在这个事件中,我将向邮件正文添加一些富文本。 但该文本仅显示在已发送的邮件文件夹中,而不显示在接收端。我错过了什么? 以下代码引用自文件 void appendRichTextToBody(NOTEHANDLE note_handle, const char *szString1) { #define PARA_STYLE_ID 1 char

我一直在尝试将一些文本附加到LotusNotes客户端发送的邮件中。为此,我已在活动前向EM_REG_注册了EM_MAILSENDNOTE。在这个事件中,我将向邮件正文添加一些富文本。 但该文本仅显示在已发送的邮件文件夹中,而不显示在接收端。我错过了什么? 以下代码引用自文件

void appendRichTextToBody(NOTEHANDLE note_handle, const char *szString1) {
    #define PARA_STYLE_ID 1
    char     itemname[] = "Body";
    WORD wBuffLen; /* required buffer length */
    BYTE *rt_field; /* allocated rich-text field */
    BYTE *buff_ptr; /* position in allocated memory */
    CDPABDEFINITION pabdef; /* rich-text paragraph style */
    CDPARAGRAPH para; /* rich-text paragraph header */
    CDPABREFERENCE ref; /* rich-text style reference */
    CDTEXT cdtext; /* rich-text text header */
    WORD wString1Len = strlen( szString1 ); /* Length of actual string */
    WORD wString1BufLen = wString1Len + (wString1Len%2);

    FONTIDFIELDS *pFontID; /* font definitions in text header */
    DWORD rt_size; /* size of rich-text field */
    STATUS error = NOERROR; /* return code from API calls */

    wBuffLen = ODSLength( _CDPABDEFINITION ) +
        ODSLength( _CDPARAGRAPH ) + ODSLength( _CDPABREFERENCE) +
        ODSLength(_CDTEXT) + wString1BufLen;

    rt_field = (BYTE *) malloc ( wBuffLen );
    if( rt_field == (BYTE *)NULL ) {
            return;
    }
    //* Keep a pointer to our current position in the buffer. */
    buff_ptr = rt_field;
    /* Initialize a CDPABDEFINITION structure.We use all defaults, except for centered
    justification.*/
    memset(&pabdef, 0, sizeof(CDPABDEFINITION));
    pabdef.Header.Signature = SIG_CD_PABDEFINITION;
    pabdef.Header.Length = ODSLength( _CDPABDEFINITION );
    pabdef.PABID = PARA_STYLE_ID;
    pabdef.JustifyMode = JUSTIFY_CENTER;
    pabdef.LineSpacing = DEFAULT_LINE_SPACING;

    pabdef.ParagraphSpacingBefore = DEFAULT_ABOVE_PAR_SPACING;
    pabdef.ParagraphSpacingAfter = DEFAULT_BELOW_PAR_SPACING;
    pabdef.LeftMargin = DEFAULT_LEFT_MARGIN;
    pabdef.RightMargin = DEFAULT_RIGHT_MARGIN;
    pabdef.FirstLineLeftMargin = DEFAULT_FIRST_LEFT_MARGIN;
    pabdef.Tabs = DEFAULT_TABS;
    pabdef.Tab[0] = DEFAULT_TAB_INTERVAL;
    pabdef.Flags = 0;
    pabdef.TabTypes = TAB_DEFAULT;
    pabdef.Flags2 = 0;
    /* Call ODSWriteMemory to convert the CDPABDEFINITION structure to
    Domino and Notes canonical format and write the converted structure into
    the buffer at location buff_ptr. This advances buff_ptr to the
    next byte in the buffer after the canonical format strucure.
    */
    ODSWriteMemory( &buff_ptr, _CDPABDEFINITION, &pabdef, 1 );
    /* Put a paragraph header in the field. */
    para.Header.Signature = SIG_CD_PARAGRAPH;
    para.Header.Length = (BYTE) ODSLength( _CDPARAGRAPH );

    ODSWriteMemory( &buff_ptr, _CDPARAGRAPH, &para, 1 );
    /* Add the CDTEXT record to the field. A CDTEXT record consists
    of a CDTEXT structure followed by a run of text. Initialize the
    CDTEXT structure by filling in the signature and the length.
    The CDTEXT structure also contains the font information that
    controls how Domino and Notes displays this first run of text.
        */
    cdtext.Header.Signature = SIG_CD_TEXT;
    cdtext.Header.Length = ODSLength( _CDTEXT ) + wString1Len ;
    pFontID = (FONTIDFIELDS *) &(cdtext.FontID);
    pFontID->Face = FONT_FACE_SWISS;
    pFontID->Attrib = ISBOLD;
    pFontID->Color = NOTES_COLOR_BLUE;
    pFontID->PointSize = 24;
    ODSWriteMemory( &buff_ptr, _CDTEXT, &cdtext, 1 );
    /* Write the actual characters of this first text run to the buffer.
    Since the run of text may contian embedded null characters, use
    memcpy, not strcpy. No need to terminate the run of text with a
    null because the Header.Length member of the CDTEXT structure
    specifies the length explicitly. Only copy the null if the
    number of characters is odd.
    */
    memcpy( (char *)buff_ptr, szString1, wString1BufLen );
    /* Advance the pointer to the next even-byte boundary */
    buff_ptr += wString1BufLen;
    rt_size = (DWORD)(buff_ptr - rt_field);
    if (error = NSFItemAppend( note_handle, 0, itemname, (WORD) strlen(itemname), TYPE_COMPOSITE, rt_field, rt_size ) ){
            Log("%s: NSFItemAppend failed\n", __FUNCTION__);
            return;
    }
    free( rt_field );
}
编辑1:

注册事件处理程序的代码:

error = EMRegister(EM_MAILSENDNOTE, EM_REG_BEFORE,(EMHANDLER)MailSendNoteHandler, gRecursionID, &hMailSendNote);
error = EMRegister(EM_NSFNOTEUPDATEMAILBOX, EM_REG_BEFORE,(EMHANDLER)UpdateMailboxHandler, gRecursionID, &hNSFUpdateMailbox);
事件处理程序函数:

STATUS MailSendNoteHandler(EMRECORD FAR * pExRecord) {
    VARARG_PTR ap = pExRecord->Ap;
    DHANDLE hNote = VARARG_GET (ap, DHANDLE);
    appendRichTextToBody(hNote, " Test Rich Text EM_MAILSENDNOTE BEFORE ");
    return (EM_ERR_CONTINUE);
}

STATUS UpdateMailboxHandler(EMRECORD FAR * pExRecord) {
    VARARG_PTR ap = pExRecord->Ap;
    DHANDLE hNote = VARARG_GET (ap, DHANDLE);
    appendRichTextToBody(hNote, " Test Rich Text EM_NSFNOTEUPDATEMAILBOX BEFORE ");
    return (EM_ERR_CONTINUE);
}
我在收件人端没有看到任何附加文本。
但“已发送”文件夹中的邮件同时包含两个附加文本。

我认为这是一个客户端EM。我熟悉的大多数邮件处理代码都是在服务器端运行的,方法是在服务器上的mail.box文件中挂接EM\u NSFNOTEUPDATE。不过,这里的诀窍是,您必须在完成处理消息之前阻止路由器发送消息,因此您要做的第一件事是将消息的状态更改为“保留”,这样路由器甚至不会尝试发送消息。然后你可以对它做你的工作,最后发布它。(通常在服务器端,这涉及发送一个单独的服务器任务来完成工作,因为您不希望在工作完成时阻止主服务器线程从NSFNoteUpdate返回。)


即使在处理之前使用EM_,您也可能需要在客户端执行类似的操作才能完成此任务。您可能至少希望为EM_NSFNOTEUPDATE添加事件处理程序之前的EM_和之后的EM_,以监视mail.box文件,以确定这些事件是在EM_MAILSENDNOTE事件激发之前还是之后激发。

您需要包含调用此方法的代码。我猜想您没有编辑通过电子邮件发送的内存中文档的正文,“但该文本仅显示在已发送的邮件文件夹中”。你的意思是你发送的邮件文档中的RT正常吗?5美分测试:检查是否存在配置问题:使用RT将邮件发送到同一收件人,他是否得到RT?最后一个想法是尝试拨打电话notesRichTextItem.Compactsending@KenPespisa我更新了我的问题,添加了更多的代码。是的,这是客户端EM。我已经更新了我的问题,现在它更具描述性。即使使用EM_nsfnoteUpdateEmailBox(之前使用EM_),我也看到了相同的行为。@Richard说的是,您的邮件是在代码运行之前发送的!因此,他说在保存消息之前更改消息的状态。EM_BEFORE应该意味着在将消息保存到mail.box之前触发事件。很难看出这里发生了什么。当您启用EM_nsfnoteUpdateEmailBox时,是否禁用了EM_SENDNOTE?我想知道NSFNOTEUDPATEMAILBOX事件是否正在发生。这可能是一个仅限服务器的事件,因为它的目的是有效地处理具有多个mailX.box文件的配置,而这些文件只能在srever上使用。对于客户端,我实际上建议只使用EM_NSFNOTEUPDATE,用您的代码过滤事件,只查看mail.box中的更新。@EmmanuelGleizer我不知道notes客户端的“消息状态”。如何改变这种情况?@RichardSchwartz我不知道禁用EM_SENDNOTE(客户端)是什么意思。关于NSFnoteUpdateEmailBox,在Lotus notes首选项->位置中,我已将“邮件文件位置”配置为本地。因此,所有发送的邮件首先保存在smtp.box文件中。我在更新smtp.box之前收到NSFnoteUpdateEmailBox,EM_。在我看来,这应该是修改便笺的正确位置,因为我实际上是在修改一个将由replicator拾取的便笺。关于EM_NSFNOTEUPDATE EM_之前,行为也没有变化。