I have the following issue. I need to get attachments from mail messages that are already downloaded in a folder (on a computer not in the mailbox).
I know how to get attachments from outlook messages. I also know how to get files from a folder and loop through them. What I can’t seem to do is treat these files as messages and therefore be able to get the attachments. I think what would help me is either convert a file variable to message variable or instead of extracting files from directory extract them directly as messages.
Would anybody be able to help me with this or does anybody have other ideas how to do this?
The best would of course be getting the mail messages directly from outlook but unfortunately this is not possible.
Hi I am getting some script error on this
Sub SaveOlAttachments()
Dim msg As Outlook.MailItem
Dim att As Outlook.Attachment
Dim strFilePath As String
Dim strAttPath As String
strFilePath = "D:\Test"
strAttPath = "D:\Test"
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
I have to open .msg files and save the attachments and get attachments name as output