Hi all,
Every day I get an email with the same subject line ("today's update") with an attachment named mavrpt########### (the #'s are numbers).
Initially I tried to get VBA to scan and save all attachments containing "mavrpt" but this didn't work.

Is it possible to scan the incoming mail for a specific subject line, and then save the attachments to the same folder :C"userprofile"\Docs:etc
renaming the file to the subject line and the day's date. or even better, overwriting the previous saved in that folder?

All other solutions I have found seem to scan entire mailboxes and save all attachments that any email contains, I get alot of attachments and do not want all of them saved constantly.

Here's what I have currently (It is not elegant and does not work at all)

Thanks in advance


Public WithEvents olItems As Outlook.Items

Sub Application_Startup()
Set olItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Sub olItems_ItemAdd(ByVal Item As Object)
Dim NewMail As Outlook.MailItem
Dim Atts As Attachments
Dim Att As Attachment
Dim strPath As String
Dim strName As String

If Item.Class = olMail Then
Set NewMail = Item
End If

Set Atts = Item.Attachments

If Atts.Count > 0 Then
For Each Att In Atts
'chooses mavrpt files
If InStr(LCase(Att.FileName), "mavrpt""*") > 0 Then
'Use your wanted destination folder path to save the attachments
strPath = "C:\Users\**Chosen Path**"
strName = MailItem.Subject & ".xls"
Att.SaveAsFile strPath & strName
End If
Next
End If

End Sub