title: Outlook VBA ReceivedTime "Invalid Qualifier"
body: <p>I'm trying to write an Outlook macro that takes a specific message (the "Selection" message as seen in the macro below) and save the message's attachment in a folder based on its ReceivedTime property. The intent is to eventually expand the macro to open the attachment in Excel and run an already-written Excel macro on it, but I'm trying to start small.</p>
  
  <p>However, whenever I try to run the macro below, it says the ReceivedTime property is an "invalid qualifier". I've never even seen this error before and have no idea what it means or what to do.</p>
  
  <pre><code>Sub DailyPinkOL()
      Call initMonths
      Dim inbox As Folder
      Dim att As Attachment
      Dim FilePath As String
      Dim SaveFolder As String
      Dim mi As MailItem
      Dim xlapp As Excel.Application
      Dim xlwb As Excel.Workbook
      Dim xlat As Excel.Workbook
      Set inbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
      If Selection.Location &lt;&gt; olViewList Then Exit Sub
      Set mi = Selection
      Set att = mi.Attachments(1)
      att.SaveAsFile Path:="path1\Current Year\" &amp; months(mi.ReceivedTime.Month) &amp; "\" &amp; mi.ReceivedTime.Month &amp; "-" &amp; mi.ReceivedTime.Day &amp; ".xlsx"
      Set xlapp = CreateObject("Excel.Application")
      Set xlwb = xlapp.Workbooks.Open("path2\file1")
  End Sub
  </code></pre>
  
  <p>path1, path2, and file1 are replaced by actual file paths and files in the actual macro; I copied it this way for security purposes.</p>