• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need to Save attachments of specific subject email and received date

Hi All,

I need your help to save email attachment of specific subject("Backup Aging dashboard") of email which received by today.

In my official inbox, am having more than 10,000 emails. I want to search only today's received email to find the specific subject email receive or not and download the related attachments.

Below the code which I try without providing the subject

Sub Attachment_save()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim O As Outlook.Application
Dim OMAIL As Outlook.MailItem
Dim ONS As Outlook.Namespace
Dim MYFOL As Outlook.Folder
Dim atmt As Outlook.Attachment

Set O = New Outlook.Application
Set OMAIL = O.CreateItem(olMailItem)
Set ONS = O.GetNamespace("MAPI")
Set MYFOL = ONS.GetDefaultFolder(olFolderInbox)
If MYFOL.Items.Count = 0 Then
MsgBox "Automation is Empty", vbInformation, "No email Found"
End If
For Each OMAIL In MYFOL.Items

For Each atmt In OMAIL.Attachments
atmt.SaveAsFile ThisWorkbook.Path & "\" & atmt.Filename
Next
Next OMAIL
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 
Back
Top