Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert image in Yagmail? (Python)

I have a Yagmail script where I want to send an email formated like so:

Hello! Below is a picture.

img.png

Goodbye!

However, my script is just sending the image all the way at the bottom of the email. Here is my code:

img = "img.PNG"
body = "Hello! Below is a picture." + img + "Goodbye!"

contents = [body, img]
yag.send("[email protected]", "Subject", contents)

How would you send an email using a format where you can position the image between blocks of text? Help is appriciated!

like image 200
Bryan Thai Avatar asked Nov 08 '22 04:11

Bryan Thai


1 Answers

contents = [yagmail.inline("/path/to/local/image")]
like image 66
Zou Angus Avatar answered Nov 14 '22 22:11

Zou Angus