I'm trying to create a code that does this:
Public Sub saveAttachment(item As Outlook.MailItem)
Dim attachment As Outlook.Attachment
Dim defaultPath As String
defaultPath = "c:\Email Exports"
For Each attachment In itm.Attachments
attachment.SaveAsFile defaultPath & "\" & attachment.DisplayName
Set attachment = Nothing
Next
End Sub
...while also being able to create subfolders per email it extracts from
Ex. John Doe - Important files has 2 attachments. VBA Code would create a John Doe - Important files folder and add the 2 attachments inside.
The default behavior would be to save them as individual files but I would like them instead to be organized per email. I have stumbled on ways to do the creation part, but it always creates a folder per attachment and not per email. I'm not sure where or how to add a createFolder for this to work in my favor.
Is this possible to do in VBA?