title: How to send emails for each person in a excel file
body: <p>So i have a file em.xlsx where i have Name &amp; Email columns, i want to send email when Name matchs the the filename in a directory</p>
  <p>How can i do that ? so far i have this code below, but it actualy return nothing</p>
  <pre><code>import glob
  import pandas as pd
  import smtplib
  from email.mime.text import MIMEText
  from email.mime.multipart import MIMEMultipart
  import os
  from collections import ChainMap
  # Spreadsheet with emails and  names
  email_list = pd.read_excel(r'C:\Users\arabw\OneDrive\Bureau\html\em.xlsx')
  folder_path= &quot;C:/Users/arabw/OneDrive/Bureau/html/&quot;
  my_files=[{each_file.split(&quot;.&quot;)[0]:each_file} for each_file in os.listdir(folder_path) if each_file.endswith(&quot;.csv&quot;)]
  my_files_dict = dict(ChainMap(*my_files))
  # getting the names and the emails
  names = email_list['Name']
  emails = email_list['Email']
   
  for i in range(len(emails)): # iterate through the records
      # for every record get the name and the email addresses
      name = names[i]
      email = emails[i]
      if my_files_dict.get(name):
          print(f&quot;file found:{my_files_dict.get(name)}&quot;) # attach this file : my_files_dict.get(name)
      #Some  help needed from here I believe
      while name == os.path:
           smtp_ssl_host = 'xxxxx'
           smtp_ssl_port = 465
           email_from = &quot;xxxxx&quot;
           email_pass = &quot;xxxxx&quot;
           email_to = email
           msg2 = MIMEMultipart()
           msg2['Subject'] = &quot;Present Record(s)&quot;
           msg2['From'] = email_from
           msg2['To'] = email
           fo=open(my_files_dict.get(name),'rb')
           attach = email.mime.application.MIMEApplication(fo.read(),_subtype=&quot;xlsx&quot;)
           fo.close()
           attach.add_header('Content-Disposition','attachment',my_files_dict.get(name))
           msg.attach(attach)
           s2 = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port)
           s2.login(email_from, email_pass)  
           s2.send_message(msg)
           s2.quit()
  </code></pre>