I'm using a similar code to the below and activating it within email rules 'run a script' and it is working fine to save attachments as certain emails come in. However, if there are multiple attachments in an email it cycles through saving them and lands on the last one. Is there a way I can tell it within the code to only save the "x" attachment, ie. only the first attachment or only the fourth attachment, etc?
*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 shareedit
answered Mar 2 '15 at 17:12*