如何解决Lotus-Notes Agent:仅从当前电子邮件中恢复文件
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
但它会恢复我电子邮件中的所有文件。而我只想从当前电子邮件(我选择的电子邮件)中恢复文件。可以这样做吗?
感谢您的帮助
解决方法
在代理属性中,您可以设置代理的“目标”是什么。默认情况下它是“选定的文档”。使用“UnprocessedDocuments”- NotesDatabase- 对象的属性使代理可以使用“目标”。
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-Mails 中的附件可能会失败。
如果您真的想获取所有附件,无论邮件的来源/类型如何,您都应该使用 @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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。