Below code is to save email attachment to a local folder. The trigger is by outlook rules. However, occasionally there will be “An unexpected error has occurred.” from Rules in Error and the code will not work as expected.
Code that I’ve tried:
<code>Sub SaveAttachmentsToFolder(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:UsersHomeSaveFolder"
For Each objAtt In itm.Attachments
obiAtt.SaveAsFile saveFolder & "” & objAtt.DisplayName
Next
End Sub
</code>
<code>Sub SaveAttachmentsToFolder(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:UsersHomeSaveFolder"
For Each objAtt In itm.Attachments
obiAtt.SaveAsFile saveFolder & "” & objAtt.DisplayName
Next
End Sub
</code>
Sub SaveAttachmentsToFolder(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:UsersHomeSaveFolder"
For Each objAtt In itm.Attachments
obiAtt.SaveAsFile saveFolder & "” & objAtt.DisplayName
Next
End Sub
New contributor
user25441505 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.