LotusScript中离不开电子邮件文件附件(LotusScript cannot get fil

2019-09-01 12:34发布

我从来没有碰到这个问题,但我不能对电子邮件中的文件附件获取句柄。 我有一些代码可以在文档中搜索嵌入对象或搜索领域的嵌入式对象 - 他们都不是返回文件。 我可以看到在电子邮件中的文件,我可以看到它包含文件附件$ FILE域中。

下面是代码:

    Function FileDetachFiles(doc As NotesDocument, fieldName As String, getFromField As Integer) As Variant

    On Error Goto ProcessError

    Dim s As NotesSession
    Dim db As NotesDatabase
    Dim rtItem As NotesRichTextItem
    Dim fileToExtract As String
    Dim fileName As String
    Dim fileArray() As String
    Dim message As String
    Dim embedObjects As Variant
    Dim attachFile As Integer
    Dim x As Integer

    Set s = New NotesSession    
    Set db = s.CurrentDatabase
    Const fileImport = "C:\"
    attachFile = False

    'Let's see if there are attached files...
    If getFromField = True Then
        'Locate field and get files...
        If doc.HasEmbedded Then
            If doc.HasItem(fieldName) Then          
                'Set the first field...
                Set rtItem = doc.GetFirstItem(fieldName)
                embedObjects = rtItem.EmbeddedObjects
                If Isarray(embedObjects) Then
                    Forall Files In rtItem.EmbeddedObjects
                        If Files.Type = EMBED_ATTACHMENT Then
                            fileName = Files.Source
                            fileToExtract = fileImport & fileName
                            Redim Preserve fileArray(x)
                            fileArray(x) = fileToExtract
                            x = x + 1
                            Call Files.ExtractFile(fileToExtract)   
                            attachFile = True               
                        End If          
                    End Forall
                End If
            End If
        End If
    Else    
        x = 0       
        'Go through doc looking for all embedded objects...
        If doc.HasEmbedded Then
            Forall o In doc.EmbeddedObjects
                If o.Type = EMBED_ATTACHMENT Then
                    fileName = o.Name
                    fileToExtract = fileImport & fileName
                    Call o.ExtractFile(fileToExtract)
                    Redim Preserve fileArray(x)
                    fileArray(x) = fileToExtract
                    x = x + 1
                    attachFile = True       
                End If      
            End Forall
        End If      
    End If

    If attachFile = True Then       
        FileDetachFiles = fileArray
    End If

    Exit Function
ProcessError:
    message = "Error (" & Cstr(Err) & "): " & Error$ & " on line " & Cstr(Erl) & " in GlobalUtilities: " & Lsi_info(2) & "."
    Messagebox message, 16, "Error In Processing..."
    Exit Function
End Function

我想这两个程序之上 - 传递$ FILE美体字段名,以及搜索文档。 它没有找到任何文件附件。

我甚至试过这样: 提取附件,MIME使用LotusScript

其中没有找到该文件的任何MIME。

我从来没有遇到这样的问题 - 任何想法将是巨大的。

谢谢!

Answer 1:

我有过,但遗憾的是不记得了,它来自哪里,它可能必须做一些事情V2-风格附件从多米诺网站来...尝试评估(@AttachmentNames)获取包含所有附件的名称的变。 然后通过这个循环有Forall-循环,并尝试NotesDocument.getAttachment(strLoopValue) - 函数来得到一个处理附件。 欲了解更多信息阅读这里并按照页面上的链接,尤其是这一个

代码将是这样的:

Dim doc as NotesDocument
Dim varAttachmentNamens as Variant
Dim object as NotesEmbeddedObject    

REM "Get the document here"
varAttachmentNames = Evaluate( "@AttachmentNames" , doc )
Forall strAttachmentName in varAttachmentNames
  Set object = doc.GetAttachment( strAttachmentName )
  REM "Do whatever you want..."
End Forall


文章来源: LotusScript cannot get file attachment from email