title: reading unopened mail from office365 in python using REST API
body: <p>How can I obtain all unopened mail (metadata and content including attachments) from office365 in python (v2.6) using a REST request?  The commented page value is returning <strong>urllib2.HTTPError: HTTP Error 400: Bad Request</strong>, while the uncommented page value works fine.  Thanks!</p>
  
  <pre><code>import urllib
  import urllib2
  
  #page = 'https://outlook.office365.com/ews/odata/Me/Inbox/Messages?$filter=IsRead'
  page = 'https://outlook.office365.com/ews/odata/Me/Inbox/Messages'
  username = "myusername"
  password = "mypassword"
  
  p = urllib2.HTTPPasswordMgrWithDefaultRealm()
  p.add_password(realm='', uri=page, user=username, passwd=password)
  handler = urllib2.HTTPBasicAuthHandler(p)
  opener = urllib2.build_opener(handler)
  urllib2.install_opener(opener)
  
  response = urllib2.urlopen(page)
  print(response.read())
  </code></pre>