title: Save Outlook attachment to a folder and Rename the file with date
body: <p>I'm trying to save the daily system generated report attached to the e-mail to a folder. </p>
  
  <p>Then, append the attachment filename with the date (modified date in the file). I am able to get the file saved to a folder. However, the renaming piece doesn't seem to work for me. </p>
  
  <p>Can someone please help why the renaming piece isn't working? Much Thanks!</p>
  
  <pre><code>Public Sub saveAttachtoBIFolder(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    Dim fso As Object
    Dim oldName As Object
  
    Dim file As String
    Dim DateFormat As String
    Dim newName As Object
  
  
    saveFolder = "C:\BI Reports"
  
  
    Set fso = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
  
    For Each objAtt In itm.Attachments
        file = saveFolder &amp; "\" &amp; objAtt.DisplayName
        objAtt.SaveAsFile file
        Debug.Print "file="; file ' the full file path printed on immediate screen
  
        Set oldName = fso.GetFile(file) ' issue seems to start from here
        DateFormat = Format(oldName.DateLastModified, "yyyy-mm-dd ")
        newName = DateFormat &amp; objAtt.DisplayName
        oldName.Name = newName
  
         Debug.Print "DateFormat="; DateFormat 'the date format printed on the immediate screen
        Set objAtt = Nothing
    Next
  
    Set fso = Nothing
   End Sub
  </code></pre>