lotus-notes - LotusScript 无法从电子邮件中获取文件附件

标签 lotus-notes mime lotus-domino lotusscript richtext

我从未遇到过这个问题,但我无法处理电子邮件中的文件附件。我的代码既可以在文档中搜索嵌入式对象,也可以在字段中搜索嵌入式对象——它们都不会返回文件。我可以在电子邮件中看到该文件,并且可以看到包含文件附件的 $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 和 Body 字段名称,以及搜索文档。它没有找到任何文件附件。

我什至试过这个: Extracting attachments as MIME using LotusScript

没有在文档中找到任何 MIME。

我从来没有遇到过这个问题——任何想法都会很棒。

谢谢!

最佳答案

我以前有过,但不幸的是不记得它是从哪里来的,它可能与来自 Domino 网站的 V2 样式附件有关... 尝试 Evaluate( @AttachmentNames ) 以获得包含所有附件名称的 Variant。然后使用 Forall- 循环遍历它并尝试 NotesDocument.getAttachment( strLoopValue ) - 函数来获取附件的句柄。 更多信息请阅读 here并点击该页面上的链接,尤其是 this one

代码应该是这样的:

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

关于lotus-notes - LotusScript 无法从电子邮件中获取文件附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16302597/

相关文章:

c# - 在 Lotus Notes 中使用 C# 将电子邮件消息另存为 eml

python - 如何使用 Python 3.2 电子邮件模块发送以 utf-8 编码并带有 quoted-printable 的 unicode 消息?

php - 检查浏览器是否支持特定的 MIME 类型?

java - Lotus Notes - 邮件文档 - 委托(delegate)人/发件人、INetFrom、SentTime、ReceivedTime 字段

database - db lotus notes的大小

java - 使用 lotus.domino 在 Notes 文档中插入图像/文件

java - Domino 9 FP10 xpages 外部 JAR

excel - 从 Excel VBA 访问 Lotus Notes 数据库 - 如何选择 COLUMNVALUES?

处理 .JS 文件的简单请求时 Tomcat 响应挂起