背景:我通过Outlook电子邮件附件从我们的电子病历系统收到一些pdf格式的每日感染控制报告。
请求:鉴于报告数量众多,我试图找到一种使用Outlook规则自动保存附件的方法。 目前,我使用的代码仅可用于保存附件及其相应的接收日期。但是,这些医疗报告在很大程度上反映了前一天的数据。因此,我想知道,如何格式化此代码,以便它将电子邮件附件的接收日期减少(减去)1天,然后自动保存到指定位置?
这是我到目前为止所拥有的:
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
答案 0 :(得分:0)
我知道了!希望此解决方案将来能对其他人有所帮助。
Sub Save_DailyFluReport(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim dateFormat As String
Dim saveFolder As String
dateFormat = Format(DateSerial(Year(itm.ReceivedTime), Month(itm.ReceivedTime), Day(itm.ReceivedTime) - 1), "dd-mmmm-yyyy")
saveFolder = "Z:\Infection Control\IP Daily Surveillance Reports"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & " - Daily Flu Report.pdf"
Set objAtt = Nothing
Next
End Sub