title: Python - win32com write email - online archive
body: <p>With this code :</p>
  <pre><code>import win32com.client
  import pandas as pd
  import os
  from datetime import datetime, timedelta
  import xlrd
  import numpy as np
  
  #######################################################################################################
  ######################################### UTILITY METH ################################################
  #######################################################################################################
  def lastOne(mess,veeamObj,first):
      for i in range(1, len(messages)):
          mess = messages[len(messages) - i]
          if ((mess.body).find(veeamObj) != -1 and (mess.body).find(first) != -1 ):
              return mess
  def sendMsg():
  
      outlook = win32com.client.Dispatch('outlook.application')
      mail = outlook.CreateItem(0)
      mail.To = 'ala@xxx.be'
      mail.Subject = 'Backup email'
      mail.Body = 'Backup'
      mail.Attachments.Add('C:/Users/ala/PycharmProjects/outlook/MonitoringBackup.xlsx')
      mail.send
  
  #######################################################################################################
  ############################################ MAIN #####################################################
  #######################################################################################################
  
  # Ouverture des fichiers outlook
  outlook = win32com.client.Dispatch(&quot;Outlook.Application&quot;).GetNamespace(&quot;MAPI&quot;)
  accounts = outlook.Folders
  print(&quot;Account : &quot; + str(accounts[5]))
  print(&quot;file : &quot; + str(accounts[5].folders[9]))
  messages = accounts[5].folders[9].Items
  
  #lecture et création de de PD
  customerList = pd.read_excel('bugs.xlsx', index_col=0)
  final = pd.DataFrame( columns=[&quot;Client&quot;, &quot;veeamObj&quot; ,&quot;veeam&quot;, &quot;date&quot;, &quot;statut&quot;])
  pd.options.display.max_columns = None
  pd.options.display.max_rows = None
  
  
  for i in range(0,len(customerList)):
      print(&quot;Pour le client : &quot; + customerList.index[i])
      trans = customerList.iloc[i]
      email = trans[0]
      email=email
      veeamObj = trans[1]
      args = int(trans[2])
      first = trans[3]
  
      mess = messages
      NbMsg = len(mess)
  
      #tri par date et par adresse
      received_dt = datetime.now() - timedelta(days=35846)
      received_dt = received_dt.strftime('%m/%d/%Y %H:%M %p')
      mess = mess.Restrict(&quot;[ReceivedTime] &gt;= '&quot; + received_dt + &quot;'&quot;)
      mess = mess.Restrict(&quot;[SenderEmailAddress] = &quot; + &quot;'&quot; + email + &quot;'&quot;)
      mess = lastOne(mess,veeamObj,first)
  
      #checking all the veeam instance
      for j in range(3, args+2):
  
          ind = (mess.body).find(trans[j])
          letter = mess.body[ind+len(trans[j])+1]
  
          if (letter == 'S'):
              print(customerList.index[i] + &quot; - &quot; + trans[j] + &quot; - &quot; + str(mess.ReceivedTime) + &quot; - ok&quot;)
              add = pd.DataFrame([[&quot; &quot;, veeamObj,str(trans[j]), str(mess.ReceivedTime), &quot;OK&quot;]], columns=[&quot;Client&quot;, &quot;veeam&quot;, &quot;date&quot;, &quot;statut&quot;])
              final = pd.concat([final, add])
          elif (letter == 'W'):
              print(customerList.index[i] + &quot; - &quot; + trans[j] + &quot; - &quot; + str(mess.ReceivedTime) + &quot; - Warning&quot;)
              add = pd.DataFrame([[&quot; &quot;, veeamObj, str(trans[j]), str(mess.ReceivedTime), &quot;Warning&quot;]], columns=[&quot;Client&quot;, &quot;veeam&quot;, &quot;date&quot;, &quot;statut&quot;])
              final = pd.concat([final, add])
          else:
              print(customerList.index[i] + &quot; - &quot; + trans[j] + &quot; - &quot; + str(mess.ReceivedTime) + &quot; - ERROR&quot;)
              add = pd.DataFrame([[&quot; &quot;, veeamObj, str(trans[j]), str(mess.ReceivedTime), &quot;ERROR&quot;]], columns=[&quot;Client&quot;, &quot;veeam&quot;, &quot;date&quot;, &quot;statut&quot;])
  
              final = pd.concat([final, add])
  print(&quot;##############################################################################&quot;)
  
  
  final.to_excel('C:/Users/ala/PycharmProjects/outlook/MonitoringBackup.xlsx', sheet_name='sheet1', index=False)
  </code></pre>
  <p>Yesterday when I launch my code all was good in minus than 1 minute stop with good the good output.
  But since today the code take a while to finish, and I've this message that appear every time  the code read message <a href="https://i.stack.imgur.com/YphXd.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I don't have idea of where to look for to resolved my issue</p>