View Single Post
 
Old 04-01-2020, 12:25 PM
NightWalker NightWalker is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2020
Posts: 3
NightWalker is on a distinguished road
Default MailItem Object explanation

I found the following code could someone explain what it is doing. I am trying to save all the attachments in an email folder to a location on my hard drive then move the email and the attachment to a subfolder. I'm trying to do this is in Outlook 2016. I dont understand the MailItem Object very well. Thank you in advance. --Walker





Code:

 For Each Item In olSubFolder.Items
        For Each Attachment In Item.Attachments
            If Attachment.Type = 1 And (InStr(Attachment, "xlsx") Or InStr(Attachment, "xls")) > 0 Then
                FileName = networkFilepath & Attachment.FileName
                'Debug.Print FileName
                Debug.Print Attachment.FileName
'                Debug.Print Item
                Attachment.SaveAsFile FileName
                
            End If
       Next Attachment
Next Item
Reply With Quote