HelloI want to mark one or more documents in a view, and export any files to a predetermined location on the server. What happens is that if i choose more than one document, so nothing is exported. What am I missing.
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
If Not doc.HasEmbedded Then Exit Sub
Set body = doc.GetFirstItem("Body")
REM Get attachments
Forall att In body.EmbeddedObjects
If att.Type = EMBED_ATTACHMENT Then
filepath$ = "C:\temp\export\" & att.Source
Call att.ExtractFile(filepath$)
Print filepath$ & " extracted"
End If
End Forall
I have tweaked your code for exporting attachments from the multiple documents. here it is…
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
If Not doc.HasEmbedded Then
Set body = doc.GetFirstItem("Attach")
Forall att In body.EmbeddedObjects
cnt=cnt+1
If att.Type = EMBED_ATTACHMENT Then
filepath$ = "C:\temp\export\" & att.Source
Call att.ExtractFile(filepath$)
Print filepath$ & " extracted"
End If
End Forall
End If
Set doc=dc.GetNextDocument(doc)
Wend
On Error Goto ErrorBlock
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
If Not doc.HasEmbedded Then
Set body = doc.GetFirstItem("Attach")
Forall att In body.EmbeddedObjects
If att.Type = EMBED_ATTACHMENT Then
filepath$ = "C:\temp\" & att.Source
Call att.ExtractFile(filepath$)
Print filepath$ & " extracted"
End If
End Forall
End If
Set doc=dc.GetNextDocument(doc)
Wend
Exit Sub
ErrorBlock:
Msgbox "Error is:" & Error() & " Error At:" & Erl
End Sub
and one more thing is check if the Agent Second tab properties for set runtime security level as third option.