Click here to Skip to main content
15,879,844 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to CC list in below code using Python
I have tried
#mail.CC = 'example1@abc.com', 'example1@abc.com'

But it is not working
Please suggest

What I have tried:

I have tried below code
Python
 <pre>

import win32com.client as win32
import datetime

# Current Day Date
current_date = datetime.datetime.today().strftime('%d-%B-%Y')
print("Current Date is: = ", current_date)

mail = win32.Dispatch('outlook.application').CreateItem(0)

mail.To = 'example1@abc.com'

#mail.CC = 'example1@abc.com', 'example2@abc.com'
mail.Subject = 'Tower Wise Status: '+current_date+''
mail.HTMLBody =\
                ' <html> ' \
                ' <body>' \
                ' <p>Hello Pratap,<br><br>'\
                ' <font size="05" color="blue">PFA Tower Wise Pendency.</font><br>' \
                ' </body>' \
                ' </html>'

attachment  = 'D:\\SBC\\01-03IRE\\18-Follow-up_Analysis\\Daily_Tower-wise.xlsx'
mail.Attachments.Add(attachment)


mail.Display(True)
Posted
Updated 19-Sep-21 22:34pm
v2
Comments
Richard MacCutchan 20-Sep-21 3:45am    
What do you mean "not working", that line is commented out in your code.
Sandeep Chavan 2021 20-Sep-21 4:08am    
Yes commented out because it is not working
Richard MacCutchan 20-Sep-21 4:20am    
See below

1 solution

The content of the CC object should be a single string containing names separated by semi-colons:
Python
mail.CC = 'VN00575957@TechMahindra.com; SS00633145@TechMahindra.com'
 
Share this answer
 
Comments
Sandeep Chavan 2021 20-Sep-21 4:39am    
Thanks its working.
Please suggest also for signature.
How do I add signature, I have Two signatures
Richard MacCutchan 20-Sep-21 4:48am    
The outlook interfaces are all documented at Microsoft.Office.Interop.Outlook Namespace | Microsoft Docs[^] .
Sandeep Chavan 2021 20-Sep-21 10:01am    
Hi Richard,
thanks but I am not able to figure out through that link.
I am beginner.
Richard MacCutchan 20-Sep-21 10:09am    
Then just put the signature in the text of the message. As far as I can see in the documentation there is no signature property in the MailItem class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900