在富文本字段中使用多个文档

时间:2017-03-24 07:29:10

标签: lotusscript

对于我的项目,每次单击“生成”按钮时,都会运行LotusScript代理,在“附件”富文本字段中创建“.pdf”文件。

这是我在一个文档上插入的脚本:

' ...

Dim oitem As NotesRichTextItem, eo As NotesEmbeddedObject, path$, template
path = Environ$("TEMP") + "\"
template = ""
Set oitem = setdoc.Getfirstitem("AttachmentCert")
If oitem.Type = RICHTEXT Then
    ForAll o In oitem.Embeddedobjects
        Set eo = o
        If eo.Type = EMBED_ATTACHMENT Then
            template = path + eo.Source
            If Dir$(template, 0) <> "" Then Kill template
            Call eo.Extractfile(template)
            Exit ForAll 
        End If
    End ForAll
End If

' ...

result = path + "Certificate of Compentency for " + names + ".pdf"
Set rtitem = New NotesRichTextItem(doc, "License_Cert")
Call rtitem.Embedobject(EMBED_ATTACHMENT, "", result)

面临的问题:如果我想将更多文档附加到富文本字段中,我该怎么办?

我尝试使用此代码,但它不起作用:

 If doc.hasItem("License_Cert") Then
    Set rtItem = doc.getFirstItem("License_Cert")
    ' Add a couple of lines to the rich text field before re-attaching the file
    Call rtItem.addNewLine(2)
 Else
    Set rtItem = New notesRichTextItem(doc, "License_Cert")
 End If

现在它复制了相同的名称字段,可以吗?

screenshot

1 个答案:

答案 0 :(得分:2)

要将多个附件附加到richtext项目,您只需执行此操作即可。您的代码看起来像这样

If doc.hasItem("License_Cert") Then
    Set rtItem = doc.getFirstItem("License_Cert")
    ' Add a couple of lines to the rich text field before re-attaching   the file
    Call rtItem.addNewLine(2)
Else
    Set rtItem = New notesRichTextItem(doc, "License_Cert")
End If

result = path + "Certificate of Compentency for " + names + ".pdf"
Call rtitem.Embedobject(EMBED_ATTACHMENT, "", result)
result = path + "Some other pdf.pdf"
Call rtitem.Embedobject(EMBED_ATTACHMENT, "", result)

Notes创建多个具有相同名称的项目是完全正常的,如果内容的大小大于特定值,只需检查任何更大邮件中的“正文”项...