cancel
Showing results for 
Search instead for 
Did you mean: 

File from collection to a folder path

blazino17
Verified Partner

I used the Get File action to retrieve an .xlsx attachment from an email, and it was successfully stored in a collection. The challenge I’m facing now is how to extract the file from the collection and save it to a specific folder path on my system.

Please assist 

1 REPLY 1

Mukeshh_k
MVP

Hi @blazino17 - I recommend using the Outlook VBO – Get Received Items (Expert), and then applying a DASL Query like this:
@SQL=urn:schemas:httpmail:sendername = 'Mukesh Kumar' AND urn:schemas:httpmail:subject LIKE '%Test Emails%' (Replace it with your Sender Name/Subject Key)

You'll also need an action to save attachments(Action should be present in the Outlook VBO), which should take the Entry ID, Folder Path, and File Pattern as inputs. The action will execute the code and save the attachments to the specified folder path. (I’m using a custom built Outlook VBO).

Mukeshh_k_3-1752484331945.png

Mukeshh_k_2-1752483978409.png

 

Mukeshh_k_1-1752483865422.png

 
Code Block:
Dim app = CreateObject("Outlook.Application")
Dim _nameSpace = app.GetNameSpace("MAPI")
 
Dim item = _nameSpace.GetItemFromID(Entry_ID)
If item Is Nothing Then Return
 
If Not Folder_Path.EndsWith("\") Then Folder_Path &="\"
 
For Each attachment As Object In item.Attachments
If (attachment.Type = 1 or attachment.Type = 5) AndAlso attachment.FileName Like File_Pattern Then
attachment.SaveAsFile(Folder_Path & attachment.FileName)
End If
Next

 

Regards,

Mukesh Kumar
#MVP