Python 通过 Outlook 在回复中添加抄送收件人

Python Add CC Recipients in Reply through Outlook

我正在通过主题在 outlook 中搜索一个项目,想对所有在 CC 中添加的 3 个 id 进行重播。

可以轻松地在“收件人”中添加更多收件人,但不能在“抄送”中添加,请帮忙

import win32com.client

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox= outlook.Folders.Item(1).Folders['Inbox']
messages = inbox.Items
message = messages.GetLast()
count=0
for i, message in enumerate(messages):
    # Search Mail
    # if message.subject=='Search Filter by Subject':
    rplyall=message.ReplyAll()
    rplyall.Recipients.Add('hitesh.kumar@bhartiaxa.com') # Sender of the mail
    rplyall.Recipients.CC('one.more@abc.com')     # Trying to do this
    rplyall.Copy('one.more@abc.com')
    rplyall.Body='Testing reply all'
    rplyall.Subject = 'Subject Reply to all 2'

    rplyall.Send()
    

正在更正我自己的问题的答案post 从上面的迈克那里得到答案post。

 import win32com.client

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox= outlook.Folders.Item(1).Folders['Inbox']
messages = inbox.Items
message = messages.GetFirst()
count=0

for i, message in enumerate(messages):
    print(message.subject)
    rplyall = message.ReplyAll()
    rplyall.Recipients.Add('hitesh@abc.com') # Sender of the mail
    rplyall.CC = 'deepak@abc.com'
    rplyall.Body = 'Testing reply all'
    rplyall.Subject = 'Subject Reply to all TEST'
    rplyall.Send()

您可以通过直接编辑 CC 属性 或更新从 [=14= 返回的 Recipient 对象返回的 Type 属性 ]

正在更新收件人类型

newCC = rplyall.Recipients.Add('one.more@abc.com')     
newCC.Type = 2 #2 = olCC

更改 CC 属性

rplyall.CC = 'one.more@abc.com;two.more@abc.com'

https://docs.microsoft.com/en-us/office/vba/api/outlook.recipients