我正在尝试像我们手动回复 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()`
由于 MailItem.Body 是一个 String 并且不可调用。 参考文档 我认为@Akhil 的答案中正确的代码是
rplyall.Body = "your message here" + rplyall.Body
rplyall.Send()