Я пытаюсь получить макрос VBA в Outlook, который сохранит вложение электронной почты в определенную папку и добавит полученную дату к имени файла.
Мой googling получил меня так далеко:
Public Sub saveAttachtoDisk (itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat As String
saveFolder = "C:\Temp\"
dateFormat = Format(Now, "yyyy-mm-dd H-mm")
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
Первая очевидная вещь заключается в том, что она применяет текущее время к имени файла вместо полученного времени, но я не могу изменить его. Моя теория заключается в том, что Outlook.Attachment не имеет ReceivedTime
и что на адрес электронной почты приходится ссылаться.
Во-вторых, это вообще не работает, ха! Он работал в первый же день, когда я начал заниматься мастерингом, но после этого он прекратил сохранять файлы.