我正在尝试发送一封带有png格式图片的电子邮件,但不知怎的,我在下面尝试的东西不起作用(电子邮件是空白的)。知道怎么做吗?
稍后我将使用一个发送到png图片的变量来定义图片显示的是X或Y.现在我只是想显示任何图片,我不能。
我的代码是(试图将身体“成像”):
from PIL import Image
imaged = Image.open('down.png')
imageu = Image.open('up.png')
imageno = Image.open('nochanges.png')
value = 0
if value > 0 :
activegraph = imageu
elif value < 0:
activegraph = imaged
elif value == 0:
activegraph = imageno
subjecttext = "erewwerew"
bodytext = """
%s
""" % imaged
import win32com.client
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = subjecttext
newMail.HTMLBody = bodytext
newMail.To = "test@test.com"
attachment1 = 'C:\\down.png'
attachment2 = 'C:\\up.png'
attachment3 = 'C:\\nochanges.png'
newMail.Attachments.Add(attachment1)
newMail.Attachments.Add(attachment2)
newMail.Attachments.Add(attachment3)
newMail.Send()