Reputation: 35
I'm currently using the yagmail module to send e-mails with Python, and I'm having difficulty embedding locally stored images into an e-mail. Is this possible?
Here's a code example:
contents = ["<img src='/path/to/local/image'>"]
yag = yagmail.SMTP('[email protected]', 'password')
yag.send('[email protected]', 'E-mail Title', contents)
Using the above code example, if I input an external path (e.g, imgur image or google image), it works perfectly, put I cannot seem to get a local path recognized.
The solution doesn't have to be using yagmail, it just seems to be the easiest e-mail module I've used so far.
Thanks for any help!
Upvotes: 2
Views: 2192
Reputation: 21451
yagmail creator here:
Try this:
contents = [yagmail.inline("/path/to/local/image")]
Upvotes: 5
Reputation: 355
You could put the image on a cloud CDN like google drive has this kind of function and send the email as HTML including the picture.
Upvotes: 0