Can anyone help me modify my code so I can download attachments?
Below is the code that I am currently using.
'**************************************************
Private Sub GetFolderInfo(fldFolder As Mapifolder)
' This procedure prints to the Immediate window information
' about items contained in a folder.
Dim objItem As Object
Dim dteCreateDate As Date
Dim strSubject As String
Dim strItemType As String
Dim strBody As String
Dim intCounter As Integer
On Error Resume Next
Debug.Print "Folder '" & fldFolder.Name & "' (Contains " & fldFolder.Items.Count & " items):"
If LCase(fldFolder.Name) = "inbox" Then
For Each objItem In fldFolder.Items
intCounter = intCounter + 1
With objItem
If LCase(.Subject) = "custom headers fix" Then
dteCreateDate = .CreationTime
strSubject = .Subject
strItemType = TypeName(objItem)
.SaveAsFile "D:\My Documents\Email Reader\test.asp"
Debug.Print vbTab & "Item #" & intCounter & " - " _
& strItemType & " - created on " _
& Format(dteCreateDate, "mmmm dd, yyyy hh:mm am/pm") _
& vbCrLf & vbTab & vbTab & "Subject: '" _
& strSubject & "'" & vbCrLf _
& strBody & vbCrLf
End If
End With
Next objItem
End If
End Sub
Private Sub Form_Load()
Dim MyNS As NameSpace
Set MyNS = Application.GetNamespace("MAPI")
Dim fldFolder As Mapifolder
Set fldFolder = MyNS.GetDefaultFolder(olFolderInbox)
Call GetFolderInfo(fldFolder)
End Sub
Below is the code that I am currently using.
'**************************************************
Private Sub GetFolderInfo(fldFolder As Mapifolder)
' This procedure prints to the Immediate window information
' about items contained in a folder.
Dim objItem As Object
Dim dteCreateDate As Date
Dim strSubject As String
Dim strItemType As String
Dim strBody As String
Dim intCounter As Integer
On Error Resume Next
Debug.Print "Folder '" & fldFolder.Name & "' (Contains " & fldFolder.Items.Count & " items):"
If LCase(fldFolder.Name) = "inbox" Then
For Each objItem In fldFolder.Items
intCounter = intCounter + 1
With objItem
If LCase(.Subject) = "custom headers fix" Then
dteCreateDate = .CreationTime
strSubject = .Subject
strItemType = TypeName(objItem)
.SaveAsFile "D:\My Documents\Email Reader\test.asp"
Debug.Print vbTab & "Item #" & intCounter & " - " _
& strItemType & " - created on " _
& Format(dteCreateDate, "mmmm dd, yyyy hh:mm am/pm") _
& vbCrLf & vbTab & vbTab & "Subject: '" _
& strSubject & "'" & vbCrLf _
& strBody & vbCrLf
End If
End With
Next objItem
End If
End Sub
Private Sub Form_Load()
Dim MyNS As NameSpace
Set MyNS = Application.GetNamespace("MAPI")
Dim fldFolder As Mapifolder
Set fldFolder = MyNS.GetDefaultFolder(olFolderInbox)
Call GetFolderInfo(fldFolder)
End Sub