Reputation: 59
I'm trying to send png with yagmail module but i get this error :
Here is the code :
import yagmail
import os
currentDirectory = os.getcwd()
path_fichier_screenshot2 = currentDirectory + "\\screenshot2.png"
print(path_fichier_screenshot2)
try:
yag = yagmail.SMTP(user="myemail", password='pwd')
contents = [yagmail.inline(path_fichier_screenshot2)]
yag.send("target_email", "test", contents)
print("Email sent successfully")
except:
print("Error, email was not sent")
When i just send text, it works. Any clue ?
Upvotes: 0
Views: 368
Reputation: 34066
If you want to send the image as an attachment, you can do this:
yag = yagmail.SMTP(user="myemail", password='pwd')
contents = "Hello , sending png as an attachment"
attachments = [path_fichier_screenshot2]
yag.send("target_email", "test", contents, attachments=attachments)
Refer to this doc
for more information.
Upvotes: 1