调用 getEmbeddedObjects(); (Domino 服务器 API)返回错误结果

发布于 2024-11-13 07:06:11 字数 337 浏览 5 评论 0原文

当从脚本发送包含附件(作为嵌入对象)的邮件时,Domino 服务器 API getEmbeddedObjects(); 返回错误结果(零)。 尽管附件是作为 EmbeddedOBject 发送的,但 getEmbeddedObjects(); 返回 ZERO。 邮件类型为NOT MIME

这是一个 Java 应用程序。这个问题有什么解决方法吗?

我从文档中取出正文。如果正文是 richtextitem,我调用 getEmbeddedObjects(),尽管附件作为嵌入对象存在,但它返回零。

The Domino server API getEmbeddedObjects(); returns the wrong result (zero) when a mail containing an attachment (as embedded object) is sent from the script.
Though an attachment is sent as an EmbeddedOBject, getEmbeddedObjects(); returns ZERO.
The mail type is NOT MIME.

This is a Java application. Is there is any workaround for this problem?

I take the body from the document. If the body is of richtextitem, I call the getEmbeddedObjects() which returns zero though an attachment is present as embedded object.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浅黛梨妆こ 2024-11-20 07:06:11

查看文档中的所有项目以查找附件的可能性是徒劳的大量工作。您需要做的就是使用 @AttachmentNames 公式获取附件名称的集合(可通过 Session 对象的 evaluate() 方法使用 Document 参数获得),如果该集合包含多个空字符串,请使用 getAttachment文档的()方法获取相应EmbeddedObject的句柄。

getAttachment() 可以抓取文档的任何附件,无论它是与 RichTextItem 还是 V2 样式附件关联(如由 Web UI 创建或在转换外部邮件时创建)。永远不要害怕在适当的时候使用公式语言——它可以让你的生活变得更加简单。

Looking through all of the items in a document for the possibility of an attachment is doing a lot of work for nothing. All you need to do is get the collection of attachment names using the @AttachmentNames formula (available through the evaluate() method of the Session object, using the Document argument), and if the collection contains more than an empty string, use the getAttachment() method of the document to get a handle to the corresponding EmbeddedObject.

getAttachment() can grab any attachment to a document, whether it's associated with a RichTextItem or a V2-style attachment (as would be created by a web UI or when converting external mail). And never be afraid to use Formula Language when it's appropriate -- it can make your life a whole lot simpler.

ぽ尐不点ル 2024-11-20 07:06:11

附件不一定必须嵌入 RichText 字段中。引用设计师帮助:

如果您需要访问文档中存在但不属于富文本项的 OLE/2 嵌入对象(例如,因为该对象最初是在文档的表单上创建的),请使用 Document 中的 EmbeddedObjects 属性。

问题的另一个根源可能是,您必须检查多个“正文”RichText 项目。

华泰

Attachments do not necessarily have to be embedded inside a RichText field. To quote from the designer-help:

If you need access to OLE/2 embedded objects that exist in a document but are not part of a rich text item (for example, because the object was originally created on the document's form), use the EmbeddedObjects property in Document.

Another source of your problem could be, that there are several "Body" RichText items you would have to check.

HTH

迎风吟唱 2024-11-20 07:06:11

遗憾的是,Lotus Notes 没有提供单一可靠的方法来从 NotesDocument 对象中提取附件。为了彻底检查,您需要检查它包含的所有富文本项目以及文档对象本身。

我编写了以下代码来从邮箱中选定的电子邮件中提取附件,以减少文件大小(我的用户保存了所有内容)。不过,主循环与您的问题相关。它显示了循环遍历文档的所有项目以查找带有附件的富文本项目的过程,然后再次循环遍历所有项目以查找“附件”类型的项目。

(请原谅代码的混乱。它不是为了提高效率而编写的)

Sub Initialize

    Set s = New NotesSession
    Set db = s.CurrentDatabase
    Set dc = db.UnprocessedDocuments
    Set doc = dc.GetFirstDocument
    Dim rtItem As NotesRichTextItem
    Dim RichTextItemNames List As String
    Dim DocumentItemNames List As String
    Dim itemCount as Integer

    While Not (doc Is Nothing)

        'Scan all richtext items in document for embedded objects
        Forall i In doc.Items

            If i.Type = RICHTEXT Then
                Set rtItem = doc.GetFirstItem(i.Name)
                If Not Isempty(rtItem.EmbeddedObjects) Then
                    RichTextItemNames(itemCount) = Cstr(i.Name)
                    itemCount = itemCount + 1
                End If
            End If

        End Forall      

        'Loop through richtext items and extract the embedded attachments
        For j = 0 To itemCount - 1 
            Set rtItem = doc.GetfirstItem(RichTextItemNames(j))
            Forall Obj In rtItem.EmbeddedObjects
                If ( Obj.Type = EMBED_ATTACHMENT ) Then
                    Call ExportAttachment(Obj)
                    Call Obj.Remove
                    Call doc.Save( False, True )  'creates conflict doc if conflict exists
                End If 
            End Forall 
        Next

        'Scan all items in document for Attachment type items
        itemCount = 0
        Forall i In doc.Items           
            If i.Type = ATTACHMENT Then

                DocumentItemNames(itemCount) = i.Values(0)
                itemCount = itemCount + 1

            End If          
        End Forall

        'Loop through all attachment items in document and extract them
        For j = 0 To itemCount - 1 
            Set attachmentObject = doc.GetAttachment(DocumentItemNames(j))
            Call ExportAttachment(attachmentObject)
            Call attachmentObject.Remove            
            Call doc.Save( False, True ) 'creates conflict doc if conflict exists
        Next        

        Set doc = dc.GetNextDocument(doc)
    Wend

End Sub

Sub ExportAttachment(o As Variant)

    Dim sAttachmentName As String
    Dim sNum As String
    Dim sTemp As String

    ' Append number to end of filename if filename exists.
    sAttachmentName = sDir & "\" & o.Source
    While Not (Dir$(sAttachmentName, 0) = "")
        sNum = Right(Strleftback(sAttachmentName, "."), 2)
        If Isnumeric(sNum) Then
            sTemp = Strleftback(sAttachmentName, ".")
            sTemp = Left(sTemp, Len(sTemp) - 2)
            sAttachmentName = sTemp & Format$(Cint(sNum) + 1, "##00") & _
            "." & Strrightback(sAttachmentName, ".")
        Else
            sAttachmentName = Strleftback(sAttachmentName, ".") & _
            "01." & Strrightback(sAttachmentName, ".")
        End If
    Wend

    Print "Exporting " & sAttachmentName
    'Save the file
    Call o.ExtractFile( sAttachmentName )


End Sub

Lotus Notes does not provide a single reliable method for extracting attachments from a NotesDocument object, unfortunately. To be thorough, you'll need to check through all richtext items it contains, as well as the document object itself.

I wrote the following code to extract attachments from selected emails in a mailbox, in an effort to cut down the file size (my users saved everything). The main loop is relevant to your question, though. It shows the process of looping through all of the document's items looking for richtext items with attachments, followed by a loop through all items again looking for items of type "Attachment".

(forgive the hackiness of the code. It wasn't written for efficiency)

Sub Initialize

    Set s = New NotesSession
    Set db = s.CurrentDatabase
    Set dc = db.UnprocessedDocuments
    Set doc = dc.GetFirstDocument
    Dim rtItem As NotesRichTextItem
    Dim RichTextItemNames List As String
    Dim DocumentItemNames List As String
    Dim itemCount as Integer

    While Not (doc Is Nothing)

        'Scan all richtext items in document for embedded objects
        Forall i In doc.Items

            If i.Type = RICHTEXT Then
                Set rtItem = doc.GetFirstItem(i.Name)
                If Not Isempty(rtItem.EmbeddedObjects) Then
                    RichTextItemNames(itemCount) = Cstr(i.Name)
                    itemCount = itemCount + 1
                End If
            End If

        End Forall      

        'Loop through richtext items and extract the embedded attachments
        For j = 0 To itemCount - 1 
            Set rtItem = doc.GetfirstItem(RichTextItemNames(j))
            Forall Obj In rtItem.EmbeddedObjects
                If ( Obj.Type = EMBED_ATTACHMENT ) Then
                    Call ExportAttachment(Obj)
                    Call Obj.Remove
                    Call doc.Save( False, True )  'creates conflict doc if conflict exists
                End If 
            End Forall 
        Next

        'Scan all items in document for Attachment type items
        itemCount = 0
        Forall i In doc.Items           
            If i.Type = ATTACHMENT Then

                DocumentItemNames(itemCount) = i.Values(0)
                itemCount = itemCount + 1

            End If          
        End Forall

        'Loop through all attachment items in document and extract them
        For j = 0 To itemCount - 1 
            Set attachmentObject = doc.GetAttachment(DocumentItemNames(j))
            Call ExportAttachment(attachmentObject)
            Call attachmentObject.Remove            
            Call doc.Save( False, True ) 'creates conflict doc if conflict exists
        Next        

        Set doc = dc.GetNextDocument(doc)
    Wend

End Sub

Sub ExportAttachment(o As Variant)

    Dim sAttachmentName As String
    Dim sNum As String
    Dim sTemp As String

    ' Append number to end of filename if filename exists.
    sAttachmentName = sDir & "\" & o.Source
    While Not (Dir$(sAttachmentName, 0) = "")
        sNum = Right(Strleftback(sAttachmentName, "."), 2)
        If Isnumeric(sNum) Then
            sTemp = Strleftback(sAttachmentName, ".")
            sTemp = Left(sTemp, Len(sTemp) - 2)
            sAttachmentName = sTemp & Format$(Cint(sNum) + 1, "##00") & _
            "." & Strrightback(sAttachmentName, ".")
        Else
            sAttachmentName = Strleftback(sAttachmentName, ".") & _
            "01." & Strrightback(sAttachmentName, ".")
        End If
    Wend

    Print "Exporting " & sAttachmentName
    'Save the file
    Call o.ExtractFile( sAttachmentName )


End Sub
段念尘 2024-11-20 07:06:11

如果您从 Document 对象获取嵌入对象,它们将不包含附件。将 getEmbeddedObjects 与“Body”RichTextItem 一起使用也可以获取附件。

这有帮助吗?

If you get the embedded objects from the Document object, they won't contain attachments. Using getEmbeddedObjects with the "Body" RichTextItem gets the attachments too.

Does that help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文