title: How can I send emails automatically through my hotmail.com account using python?
body: <p>So I've been trying to send an email programmatically using my @hotmail.com account.</p>
  
  <p>What I've succeeded in doing so far:</p>
  
  <ol>
  <li>Create an app here <a href="https://apps.dev.microsoft.com/#/appList" rel="nofollow noreferrer">https://apps.dev.microsoft.com/#/appList</a> and have:
  
  <ol>
  <li>an Application ID</li>
  <li>a Password under "Application Secrets</li>
  <li>Under plaftorms I've added a web and a Native Application</li>
  <li>Under Graph Permissions I've got under Delegated Permissions "Mail.Send" and "User.Read"</li>
  </ol></li>
  <li>I've successfully managed to run <a href="https://github.com/microsoftgraph/python-sample-send-mail" rel="nofollow noreferrer">this</a> code to send an email through the browser.
  
  <ol>
  <li>However, I was asked to log in as part of the process to authenticate.</li>
  </ol></li>
  </ol>
  
  <p>The question is the following:</p>
  
  <p>How can I send an email through python and using my @hotmail.com account without having to provide any login credentials each time?</p>
  
  <p>The ideal solution would be a simple <code>sendmail(to, subject, body)</code> (or similar) and a config file with an app specific password (which I think I already have).</p>
  
  <p>Initially, I had hoped to look through the sample python code from the above link (repeated <a href="https://github.com/microsoftgraph/python-sample-send-mail/blob/master/sample.py" rel="nofollow noreferrer">here</a>) and try to adapt it but that wouldn't be the right approach given the sample code requires a login through the browser.</p>