繁体   English   中英

Lotus-Notes 代理:仅从当前 email 恢复文件

[英]Lotus-Notes Agent: Recover only the files from the current email

目前在我的代理中,我浏览我的 email 文件,如下所示:

    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim item As Variant
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument

    Dim myServer As String
    Dim myMailfile As String

    myServer = <server>
    myMailfile = <mailfile>
    ' *** Open the specified mail file using back-end classes
    Set db = New NotesDatabase(myServer, myMailfile)
    
    If Not (db Is Nothing) Then
        Set view = db.GETVIEW("$Inbox")
        If Not (view Is Nothing) Then
            Call view.Refresh
            Set doc = view.GETFIRSTDOCUMENT
            Do While Not doc Is Nothing
                On Error Resume Next
                Set item = doc.GETFIRSTITEM("Body")
                If doc.HasEmbedded Then
                    item.EmbeddedObjects
                    ForAll attachment In item.EmbeddedObjects
                        Call attachment.ExtractFile ("C:\Users\admin\Documents\files\" & attachment.Name)
                    End ForAll
                End If
                Set doc = view.GETNEXTDOCUMENT(doc)
            Loop
        End If
    End If

但它会恢复我电子邮件中存在的所有文件。 而我只想从当前 email(我选择的 email)中恢复文件。 有可能这样做吗?

谢谢您的帮助

在代理属性中,您可以设置代理的“目标”是什么。 默认情况下,它是“选定的文档”。 使用 NotesDatabase-Object 的“UnprocessedDocuments”属性使代理可以使用“目标”。

Dim dc as NotesDocumentCollection
Set db = session.CurrentDatabase '- get the database where the agent runs
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument()
While not doc is Nothing
    '- here comes the inner code from your own while loop
    Set doc = dc.GetNextDocument( doc )
Wend

只有一件事: item.EmbeddedObjects 不会获得您邮件的所有附件。 MIME-邮件中的附件可能会失败。

如果您真的想获取所有附件,无论邮件的来源/类型如何,您都应该使用 @AttachmentNames(0) - 解决方法:

Dim arrAttachments as Variant
Dim embObj as NotesEmbeddedObject

arrAttachments = Evaluate( "@Attachmentnames(0)" )
Forall strAttachment in arrAttachments
  Set embObj = doc.GetAttachment(strAttachment)
  Call embObj.ExtractFile ("C:\Users\admin\Documents\files\" & embObj.Name)
End Forall
  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM