Background: I receive several daily Infection Control Reports in pdf format from our electronic medical records system via Outlook email attachments.
Request: Given the large number of reports, I am trying to find a way to autosave the attachments using an outlook rule. Currently, the code I use works only to save the attachment with its respective received date. However, these medical reports largely reflect the previous day's data. Therefore, I was wondering, How would I format this code so that it will take the email attachment's received date less (minus) 1 day, and autosave it in a specified location?
Here is what I have so far:
Sub Save_DailyFluReport(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim dateFormat As String
Dim saveFolder As String
dateFormat = Format(itm.ReceivedTime, "dd-mmmm-yyyy")
saveFolder = "Z:\Infection Control\IP Daily Surveillance Reports"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & " - " & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub