我正在尝试回复outlook电子邮件,就像我们手动回复以前的对话一样。但是下面的代码给出了一些错误:未能发送到收件人地址..我需要知道如何将它发送回给发送我电子邮件的人..
import win32com.client, datetime
from datetime import timedelta
outlook =win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") # to trigger outlook application
inbox = outlook.GetDefaultFolder(6) # 6 is used for the index of the folder
messages = inbox.Items
message = messages.GetLast()# message is treated as each mail in for loop
for message in messages:
if message.Subject=="request": # based on the subject replying to email
#body_content = message.body
message.Reply()
message.Body = "shortly will be processed!!!"
message.Send()
回复是由reply()返回的MailItem。所以试试这个:
reply = message.Reply()
reply.Body = "shortly will be processed!!!"
reply.Send()
继续上面的答案
回复所有:
`rplyall=message.ReplyAll()`
反映以前的对话:
`rplyall.Body="your message here"+rplyall.Body()`
`rplyall.Send()`
Since MailItem。主体是一个字符串,它是不可调用的。参考文档我认为@Akhil的答案中正确的代码是
rplyall.Body = "your message here" + rplyall.Body
rplyall.Send()