title: SMTP AttributeError 'float' object has no attribute 'encode'
body: <p>I have an error here all the code works well but when i try to send the message i have this error, i looked on Internet but i didn't found how to fix, could you help me?
  curious is that the code works and send email correctly with the attached pdf, but send me that message</p>
  <pre><code>import pandas, smtplib
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  from email.mime.application import MIMEApplication
  
  # Put your email and pws here
  
  MY_EMAIL = &quot;sample@gmail.com&quot;
  PASSWORD = &quot;sample&quot;
  
  # Put your PDF path here
  PDF_PATH = &quot;Sample_pdf.pdf&quot;
  
  # Email Subject
  SUBJECT = &quot;PUT HERE YOUR SUBJECT&quot;
  
  # Read the email list
  email_data = pandas.read_csv(&quot;Emails.csv&quot;)
  email_dict = email_data.to_dict(orient='records')
  
  # Server connection
  server = smtplib.SMTP('smtp.gmail.com')
  server.starttls()
  server.login(user=MY_EMAIL,password=PASSWORD)
  
  for person in email_dict:
      msg = MIMEMultipart()
      message = f'Message send from Hostname: {MY_EMAIL}'
      msg['Subject'] = SUBJECT
      msg['From'] = MY_EMAIL
      msg['To'] = person['mail']
      # Insert here the text to the msg going vy email
      msg.attach(MIMEText(message,&quot;plain&quot;))
      # Attach the pdf to de msg
      with open(PDF_PATH,&quot;rb&quot;) as f:
          attach = MIMEApplication(f.read(),_subtype=&quot;pdf&quot;)
      attach.add_header('Content-Disposition','attachment',filename=str(PDF_PATH))
      msg.attach(attach)
      # Send msg
      server.send_message(msg)  # Here is the line of error
  ```
  [Code error][1]
  
  
    [1]: https://i.stack.imgur.com/LHP3z.png
  </code></pre>