4

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
  • 21,963
  • 12
  • 64
  • 91
user423803
  • 41
  • 1
  • 1
  • 2

2 Answers2

2

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

Sun
  • 6,480
1

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

CharlieRB
  • 23,021
  • 6
  • 60
  • 107