How can I solve the below error. The message is as below in splitting the Test emails with a semi-colon? Ideally I should send emails from Sendfrom corresponding emails in Test.
test
SENDFROM Test
xx@gmail.com xxxx@vvv.com;yyy@gggfg.com;tiitioo@ggg.com
yy@xxx.com ggg@vvv.com;yyy@gggfg.com;vvv@ggg.com
AttributeError: 'Series' object has no attribute 'split'
My code is below:
import smtplib, ssl
from email.message import EmailMessage
import getpass
email_pass = getpass.getpass() #Office 365 password
# email_pass = input() #Office 365 password
context=ssl.create_default_context()
for idx, row in test.iterrows():
emails = test['Test']
sender_list = test["SENDFROM"]
smtp_ssl_host = 'smtp.office365.com'
smtp_ssl_port = 587
email_login = "xx@xx.com"
email_from = sender_list
email_to = emails
msg2 = MIMEMultipart()
msg2['Subject'] = "xxx"
msg2['From'] = sender_list
msg2['To'] = ", ".join(email_to.split(";"))
msg2['X-Priority'] = '2'
text = ("xxxx")
msg2.attach(MIMEText(text))
s2 = smtplib.SMTP(smtp_ssl_host, smtp_ssl_port)
s2.starttls(context=context)
s2.login(email_login, email_pass)
s2.send_message(msg2)
s2.quit()