title: How to save attachment from outlook using win32com.client in Python?
body: <p>Im trying to read email and download the attachment to my own folder using win32com module in Python, I stopped at getting the attachment object:</p>
  
  <pre><code>from win32com.client import Dispatch
  import datetime as date
  
  outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
  inbox = outlook.GetDefaultFolder("6")
  all_inbox = inbox.Items
  val_date = date.date.today()
  
  sub_today = 'Hi'
  att_today = 'Attachment.xlsx'
  for msg in all_inbox:
      if msg.Subject == sub_today:
          break
  
  for att in msg.Attachments:
      if att.FileName == att_today:
          break
  
  att.SaveAsFile('new.xlsx')
  att.ExtractFile('new.xlsx')
  open(att)    
  att.WriteToFile('x')
  </code></pre>
  
  <p>None of the last 4 lines work...</p>
  
  <pre><code>&gt;&gt;&gt; att.ExtractFile('new.xlsx')
  raise AttributeError("%s.%s" % (self._username_, attr))
  AttributeError: &lt;unknown&gt;.ExtractFile
  
  &gt;&gt;&gt; open(att) 
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: coercing to Unicode: need string or buffer, instance found
  
  &gt;&gt;&gt; att.WriteToFile('x')
   raise AttributeError("%s.%s" % (self._username_, attr))
  AttributeError: &lt;unknown&gt;.WriteToFile
  </code></pre>
  
  <p><code>att.SaveAsFile('new.xlsx')</code> has no error, but there is no such file in the working directory. Seems that the line was just ignored...</p>
  
  <p>Could anyone help? Thanks in advance!</p>