0

I have managed to edit well known VBA script for saving outlook attachments, which I found here to change the attachment name to hour, minute and second in which was message recieved. After a lot of attemps I cant seem to figure out how to change the file name to be show as hh:nn:ss - 17:19:52 for example. Currently it shows it as 17-19-52. When i simply replace "-" with ":" I get an error. Any suggestions? Thank you.

Sub Save_DailyFluReport(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim timeFormat As String
Dim saveFolder As String

timeFormat = Format(TimeSerial(Hour(itm.ReceivedTime), Minute(itm.ReceivedTime), Second(itm.ReceivedTime)), "hh-nn-ss")
saveFolder = "C:\Sken"
    For Each objAtt In itm.Attachments
          objAtt.SaveAsFile saveFolder & "\" & timeFormat & ".pdf"
        Set objAtt = Nothing

     Next
End Sub
robsik
  • 9
  • 6

0 Answers0