automatically Save outlook attachment

32,193

Solution 1

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

Solution 2

If your Outlook account is POP3 or IMAP, you can not run macros or rules while your client is closed because there is no way to trigger your event other than incoming messages.

If you are running Outlook on Exchange, you would need to create a rule on the server for your account to save attachments before delivered to your Inbox. The rule will need the UNC address (\\server\folder, not a local mapped drive address (D:\folder) which the server doesn't recognize.

Keep in mind, your network administrator may have disabled server side rules for security reasons. You should check with them to ensure you are able to do this.

Additional info: Client-side and server-side rules

Share:
32,193

Related videos on Youtube

Raystafarian
Author by

Raystafarian

Updated on September 18, 2022

Comments

  • Raystafarian
    Raystafarian over 1 year

    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 
    
    • Raystafarian
      Raystafarian about 9 years
      What if you target the macro to something like savefolder = "/server/path/to - does it then hit the server? Or are you looking to upload via a web interface like sharepoint?