fourclicks
03-09-2016, 12:23 PM
I have an outlook rule set up to run a script that automatically downloads attachments when the email is received and prepends the filename with the date, time, and a random number (to prevent overwrites with files of the same name). Every once in a while the rule will experience an error and turn itself off. I want to know what's causing the error, and I suspect it might have to do with trying to retrieve the time but I can't know for certain. My question is what would be the best way to try and track down the cause of this error?
Here's the script:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
dateFormat = Format(Now, "yyyy-mm-dd H-mm-ss ") & Rnd & " FILENAME = "
saveFolder = "C:\Users\User\Desktop\EFAX EMAIL\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
Here's the script:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
dateFormat = Format(Now, "yyyy-mm-dd H-mm-ss ") & Rnd & " FILENAME = "
saveFolder = "C:\Users\User\Desktop\EFAX EMAIL\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & dateFormat & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub