title: Trying to automate a data pull process using python and email trigger
body: <p>I have been trying to create a python script to be run on a Linux server where it will check for a specific email in my mailbox and then trigger a sas script.</p>
  <p>Currently, my approach is using python's imaplib. The exact steps to my approach are:</p>
  <ol>
  <li>Email is received in my Outlook folder</li>
  <li>This email is forwarded to a gmail account through Outlook trigger.</li>
  <li>The gmail account is linked to python via imaplib and receives only THESE SPECIFIC EMAILS(frequency is monthly)</li>
  <li>I need to create a code that will monitor the inbox of this email and trigger the sas script when there is a new email detected in gmail.</li>
  </ol>
  <p>I am a noob to python and any help in this regard would be a godsend.</p>
  <pre><code>import imaplib,email
  imap_server = 'imap.gmail.com'
  email_id = ''
  password = ''
  imap = imaplib.IMAP4_SSL(imap_server)
  imap.login(email_id,password)
  imap.select(&quot;Inbox&quot;)
  imap.search(None,'ALL')
  </code></pre>
  <p>This is my current code. Although, when using imap.search(None,'NEW'), i'm getting an error. What should the next steps be? I want to check if there is any new email in the mailbox, if yes then trigger the sas script.</p>
  <p>Also, please note that this python will be running in the Linux system where the sas code is present.</p>