title: Refresh Outlook folder and wait before going further
body: <p>I'd like to refresh an Outlook folder with Python and wait for it to be updated before going further with the code.</p>
  <p>This is my piece of code, which works without errors.</p>
  <pre><code>import win32com.client
  import time
  
  outlook = win32com.client.Dispatch('outlook.application')
  mapi = outlook.GetNamespace(&quot;MAPI&quot;)
  fOutlook = mapi.Folders('xxx@gmail.com').Folders['Inbox']
  mapi.SendAndReceive
  time.sleep(10)  # wait 10 secs
  
  #further code here
  </code></pre>
  <p>As correctly reported here <a href="https://stackoverflow.com/questions/56119181/refresh-outlook-inbox-via-python-script">Refresh outlook inbox via python script</a>,   <code>mapi.SendAndReceive</code> is asynchronous. I've then somehow to wait for the result before proceeding.</p>
  <p>Questions:</p>
  <ol>
  <li><p>I don't like the <code>time.sleep()</code> function as of course I don't know in advance how long it takes to sync the folder. Any better way to wait for sync completion?</p>
  </li>
  <li><p>With <code>mapi.SendAndReceive</code> I'm updating all the email accounts in Outlook (I've 4 of them...). How to sync a specific folder only? I tried with <code>fOutlook.SendAndReceive</code> but returns an error</p>
  </li>
  </ol>