Monday, October 30, 2017

Download the attachments from path to To path

Public Function FnDownloadAttachments(ByVal FromPlace, ByVal ToPlace, ByVal fileName)
   FnDownloadAttachments = 0

   If Right(ToPlace , 1) <> "\" Then
ToPlace = ToPlace & "\"
   End If

Dim oFindAttachments
oFindAttachments = FnFindAttachment(FromPlace, fileName)

Set FSO = CreateObject ("Scripting.FileSystemObject")
Dim index

For index = LBound(oFindAttachments) to UBound(oFindAttachments)
oFindAttachments(index).Load True, ""
FSO.CopyFile oFindAttachments(index).FileName, _
ToPlace & oFindAttachments(index).Name(1), True

FnDownloadAttachments = FnDownloadAttachments + 1
Next
End Function

No comments:

Post a Comment