The below code extracts attachments from *.msg files stored in one folder.
I'm seeking to extract attachments from *.msg files stored in many subfolders within a folder.
The path for the main Folder is:
U:\XXXXX\XXXXX\Main Folder
The paths for the subfolders are:
U:\XXXXX\XXXXX\Main Folder\Folder1
U:\XXXXX\XXXXX\Main Folder\Folder2
U:\XXXXX\XXXXX\Main Folder\Folder3
etc.
Sub SaveOlAttachments()
Dim msg As Outlook.MailItem
Dim att As Outlook.Attachment
Dim strFilePath As String
Dim strAttPath As String
'path for msgs
strFilePath = "U:\XXXXX\XXXXX\Main Folder\"
'path for saving attachments
strAttPath = "D\Attachments\"
strFile = Dir(strFilePath & "*.msg")
Do While Len(strFile) > 0
Set msg = Application.CreateItemFromTemplate(strFilePath & strFile)
If msg.Attachments.Count > 0 Then
For Each att In msg.Attachments
att.SaveAsFile strAttPath & att.FileName
Next
End If
strFile = Dir
Loop
End Sub