title: How to iterate through emails and their attachments Python win32
body: <p>I'm trying to find all emails sent to specific person ('Andrew' for demo purposes) and then to find attachment in each of this mail that contains string in its name (there are multiple attachments added to each mail). </p>
  
  <p>Here is the code: </p>
  
  <pre><code>peopleInitials = ['XXX','YYY', 'ZZZ']
  checkText = 'Andrew'
  listalen = len(peopleInitials)
  
  for message in messages:
       k = 0
       currentText = message.To     
       if checkText in currentText:
            for att in message.Attachments:
                 attachmentName = att.FileName
                 while k &lt; listalen:
                      if peopleInitials[k] in attachmentName:
                           print('Atachment exists')
                           print(attachmentNames)
                      else: 
                           print('Attachment does not exist')
                           print(attachmentNames)
                      k = k + 1
  </code></pre>
  
  <p>It works partially- it iterates through e-mails and when it finds one addressed to Andrew it checks if attachment name contains 'XXX', 'YYY' or ''ZZZ. However it only checks one attachment for every e-mail and does not iterate through all its attachments. What am I doing wrong? Many thanks in advance</p>
  
  <p>Using Outlook2016, Python 3.7 and win32com</p>