在富文本字段中附加多个文档

Attach more than one document using in a rich text field

对于我的项目,每次单击生成按钮时,运行 LotusScript 代理都会在 "attachment" 富文本字段中创建一个“.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

现在重复同名字段,可以吗?

要将多个附件附加到富文本项目,您只需这样做。你的代码看起来像这样

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 创建多个同名项目是完全正常的,如果内容的大小大于特定值,只需检查任何更大邮件中的 "Body" 项目...