LotusScript无法从电子邮件获取文件附件 [英] LotusScript cannot get file attachment from email

查看:131
本文介绍了LotusScript无法从电子邮件获取文件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从未遇到过这个问题,但是我无法处理电子邮件中的文件附件.我有可以在文档中搜索嵌入式对象"或在字段中搜索嵌入式对象"的代码-它们都不返回文件.我可以在电子邮件中看到文件,也可以看到包含文件附件的$ FILE字段.

I had never run into this problem, but I cannot get a handle on a file attachment on an email. I have code that can either search the document for Embedded Objects or search a field for Embedded Objects -- neither of them are returning the file. I can see the file on the email and I can see the $FILE field which contains the file attachment.

这是代码:

    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字段名称,以及搜索文档.它找不到任何文件附件.

I tried both routines above -- passing the $FILE and Body field names, as well as searching the document. It does not find any file attachments.

我什至尝试了这个: 使用LotusScript将附件提取为MIME

I even tried this: Extracting attachments as MIME using LotusScript

在文档上找不到任何MIME.

Which did not find any MIME on the document.

我从来没有遇到过这个问题-任何想法都很棒.

I have never run into this problems -- any ideas would be great.

谢谢!

推荐答案

我以前有过,但是不幸的是,我不记得它的来源,它可能必须对Domino网站上的V2-样式附件进行某些处理. . 尝试使用Evaluate(@AttachmentNames)获得包含所有附件名称的Variant.然后使用Forall循环遍历此过程,并尝试使用NotesDocument.getAttachment(strLoopValue)-函数来获取附件的句柄. 有关更多信息,请在此处并按照该页面上的链接进行操作,特别是这一个

I had that before, but unfortunately do not remember, where it comes from, it might have to do something with V2- Style Attachments coming from Domino Websites... Try Evaluate( @AttachmentNames ) to get a Variant containing the names of all attachments. Then loop through this with a Forall- loop and try the NotesDocument.getAttachment( strLoopValue ) - Function to get a handle to the attachment. For further info read here and follow the links on that page, especially 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

这篇关于LotusScript无法从电子邮件获取文件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆