rynax.blogg.se

How do i add a gif to outlook email
How do i add a gif to outlook email












how do i add a gif to outlook email how do i add a gif to outlook email

MsgText = MIMEText('Some HTML text and an image.KPI-DATA!', 'html') MsgText = MIMEText('Alternative plain text message.') MsgAlternative = MIMEMultipart('alternative') MsgRoot.preamble = 'Multi-part message in MIME format.' I have edited for attaching the image on a message body and HTML template. You'll notice that this is quite similar to the "asparagus" example from the email examples documentation in the Python standard library. # print(msg.as_string()), or go ahead and send New code should avoid the explicit creation of individual MIME parts like in the above code, and probably look more something like from ssage import EmailMessageįp.read(), 'image', 'jpeg', cid=attachment_cid) Since Python 3.6, Python's email library has been upgraded to be more modular, logical, and orthogonal (technically since 3.3 already really, but in 3.6 the new version became the preferred one). Print(msg.as_string()) # or go ahead and send it Img.add_header('Content-ID', ''.format(attachment)) Msg.attach(msgText) # Added, and edited the previous line MsgText = MIMEText('%s' % (body, attachment), 'html') from import MIMEMultipartįrom import MIMEText # Added

how do i add a gif to outlook email

However, see below for a modernized version. I have not attempted to send the resulting message. The following is an edit of your script with the missing pieces added. A multipart message by itself has no contents at all, you have to add a text part if you want a text part.

how do i add a gif to outlook email

You should probably begin by understanding what the proper MIME structure looks like. You are going through royal pains to construct a valid MIME message in msg, then ditching it and sending a simple string email_message instead. #ndmail(from_addr, to_addr, msg.as_string())Īs you can tell from the code above I've tried different ways (referencing the #) #email_message = '%s\n%s\n%s' % (subject_header, body, img)Įmail_message = '%s\n%s' % (subject_header, body)ĮmailRezi = smtplib.SMTP(mail_server, mail_server_port)ĮmailRezi.login(mail_username, mail_password)Įndmail(from_addr, to_addr, email_message) Note that I am using Python 3.2.2.Īny guidance would be appreciated. I have researched online and the solutions are not working for me. I've come across a problem where I can attach the email but my quotes no longer work. I'm now trying to embed an image in the email as well. I currently have a program that will randomly select quotes from a list and email them.














How do i add a gif to outlook email