Outlook – automatically Save outlook attachment

automationemailmicrosoft-outlookssisvba

Is there a Windows-based method that can automatically pull save email attachment from a outlook 2010 to a server?
I get aan email daily with an attachment that I manually save to a folder on a server.
I need to automate this process.

What I've tried –

i tried to create a rule in outlook and a script to it. but it only saves the attachment to my local folder on my pc. and it only saves when outlook is opened. i want it to save to a server and save even if outlook is not opened on the server.here is the script i saved in outlook

Public Sub saveAttachtoDisk(itm As Outlook.MailItem) 
Dim objAtt As Outlook.Attachment 
Dim saveFolder As String 
saveFolder = "D:\newfolder" 
  For Each objAtt In itm.Attachments 
    If InStr(objAtt.DisplayName, ".xls") Then 
    objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName 
    End If 
  Set objAtt = Nothing 
  Next 
End Sub 

Best Answer

Running VBA is a client-side only operation. This means your PC has to be on and Outlook has to be running with scripting enabled. If you don't have Outlook running, what you want is not possible. Perhaps there is a server side solution, but that is a question for serverfault.com

If you want to process attachments on specific e-mails, this is what I use. It works perfectly for me in Outlook 2013:

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\temp"
     For Each objAtt In itm.Attachments
          objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
          Set objAtt = Nothing
     Next
End Sub

The last part of the rule is the run a script.

enter image description here

For others that are not familiar with Outlook VBA, you need to bring up the Developer Ribbon.

enter image description here

Paste the code above, save the VBA, then reference it in your rule.

enter image description here

Related Question