I currently have a program that will randomly select quotes from a list and email them. I'm now trying to embed an image in the email as well. I've come across a problem where I can attach the email but my quotes no longer work. I have researched online and the solutions are not working for me. Note that I am using Python 3.2.2.
Any guidance would be appreciated.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
attachment = 'bob.jpg'
msg = MIMEMultipart()
msg["To"] = to_addr
msg["From"] = from_addr
msg["Subject"] = subject_header
#msgText = MIMEText(<b>%s</b><br><img src="cid:bob.jpg"><br>, 'html') % body
fp = open(attachment, 'rb')
img = MIMEImage(fp.read())
fp.close()
msg.attach(img)
#email_message = '%s\n%s\n%s' % (subject_header, body, img)
email_message = '%s\n%s' % (subject_header, body)
emailRezi = smtplib.SMTP(mail_server, mail_server_port)
emailRezi.set_debuglevel(1)
emailRezi.login(mail_username, mail_password)
emailRezi.sendmail(from_addr, to_addr, email_message)
#emailRezi.sendmail(from_addr, to_addr, msg.as_string())
emailRezi.quit()
As you can tell from the code above I've tried different ways (referencing the #)