Reputation: 1329
I am searching an item in outlook through subject , want to do replay to all adding 3 ids in CC.
Easily able to add more recipients in To but not in CC please help
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('[email protected]') # Sender of the mail
rplyall.Recipients.CC('[email protected]') # Trying to do this
rplyall.Copy('[email protected]')
rplyall.Body='Testing reply all'
rplyall.Subject = 'Subject Reply to all 2'
rplyall.Send()
Upvotes: 0
Views: 3657
Reputation: 1329
Correcting the answer to my own question post getting the answer from Mike in above 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('[email protected]') # Sender of the mail
rplyall.CC = '[email protected]'
rplyall.Body = 'Testing reply all'
rplyall.Subject = 'Subject Reply to all TEST'
rplyall.Send()
Upvotes: 0
Reputation: 644
You can add CC recipients by editing the CC
property directly or updating the Type
property of the returned from the returned Recipient object from Recipients.Add
Updating the recipient type
newCC = rplyall.Recipients.Add('[email protected]')
newCC.Type = 2 #2 = olCC
Changing the CC property
rplyall.CC = '[email protected];[email protected]'
https://learn.microsoft.com/en-us/office/vba/api/outlook.recipients
Upvotes: 2