Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

rocky

Need script to autosave outlook attachments to SFTP folder

I hope someone can help me on this. I have been struggling to find a solution for this for the last couple of weeks. I don't know VB or scripting but I can follow the directions. My work's requirement is that when an email with attachment comes from a specific email address, the attachment files from that email should automatically be saved to a SFTP folder. I am able to save the attachments to a local folder using a combination of Outlook rule (run a script when received an email with attachment) and outlook script (see in the end of this message). After this, from the local folder, I can transfer the files to the sftp using Winscp command in the windows task scheduler. However, I really need to avoid step 2. We want to save the attachments directly to SFTP folder from Outlook 2016. I think that perhaps I can do this by initiating WINSCP in the background with outlook like I did using windows task scheduler. Please let me know if someone can help on this. : )

The outlook script to save the attachment to a local folder:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.attachment
Dim saveFolder As String
saveFolder = "local folder location here"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub