title: Import Outlook attachment directly into PowerShell
body: <p>I have some code that is getting the attachments from a single Outlook email, saving it as a file and then importing it into an object using <code>Import-CSV</code>:</p>
  <pre><code>ForEach ($m in $emails) { ## Save email attachments
  if ($m.ReceivedTime.ToString(&quot;dd/MM/yyyy&quot;) -eq (Get-Date).AddDays(-$DateReduction).ToString(&quot;dd/MM/yyyy&quot;)) {
      $m.Attachments | Where-Object {$_.FileName -like &quot;Payment Processes*&quot;} | 
          ForEach-Object {
              if ($_.FileName -like '*TTT*') {
                  $_.SaveAsFile(&quot;$($ENV:Temp)\T_$($(Get-Date).AddDays(-$DateReduction).ToString('dd-MM-yyyy')).csv&quot;)
                  $Data_T = Import-CSV &quot;$($ENV:Temp)\T_$($(Get-Date).AddDays(-$DateReduction).ToString('dd-MM-yyyy')).csv&quot;
              }
              elseif ($_.FileName -like '*NNN*') {
                  $_.SaveAsFile(&quot;$($ENV:Temp)\N_$($(Get-Date).AddDays(-$DateReduction).ToString('dd-MM-yyyy')).csv&quot;)
                  $Data_N = Import-CSV &quot;$($ENV:Temp)\N_$($(Get-Date).AddDays(-$DateReduction).ToString('dd-MM-yyyy')).csv&quot;
              }
          }
      }
  }
  
  $Data_T
  $Data_N
  </code></pre>
  <p>This works fine, but what i want to do is skip the step of saving the file. Is it possible to pipe the attachments i get from Outlook directly into <code>Import-CSV</code> to create the variables?</p>