-1

I am creating the automatic mail system which I have to send the filtered excel values daily

I filtered the excel values using Pandas and stored that in status, while sending mail using python I got some error like this

TypeError: sequence item 1: expected str instance, Series found

Code:

samples = pd.read_excel(excel_file,sheet_name=0)
status=samples.STATUS == "Need to Update"
msg=EmailMessage()
msg['Subject']='Limit Sample Management System'
msg['From']='[email protected]'
msg['To']='[email protected]'
msg.set_content("Kindly Go-Through the below mail",status)
mail=smtplib.SMTP("smtp.gmail.com",587)


mail.login('[email protected]','123')

mail.send_message(msg)

mail.close()

I need to send that filtered values only

5
  • 3
    You're making us guess where the error is. Please edit the question to include the full error traceback message. May 2, 2019 at 16:17
  • 3
    Also, show us how you create msg. May 2, 2019 at 16:18
  • 1
    msg=EmailMessage() msg['Subject']='Limit Sample Management System' msg['From']='[email protected]' msg['To']='[email protected]' msg.set_content("Kindly Go-Through the below mail",status) May 2, 2019 at 16:19
  • And sorry for that I am really new to this May 2, 2019 at 16:22
  • 1
    Add the additional code in your question rather than in the comments.
    – petezurich
    May 2, 2019 at 16:41

1 Answer 1

0

The error is from this line:

msg.set_content("Kindly Go-Through the below mail",status)

The error tells you that status is a pandas.Series. msg.set_content cannot handle it, you must convert the series into a string.
Try for example with

body = ' '.join(map(str, list(status))))
msg.set_content("Kindly Go-Through the below mail",body)

body is a concatenation of all the values in the series converted to a string (if they are already strings, you may omit the map function).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.