I want to write code that sends out emails to multiple clients (individually).
address = ['[email protected]','[email protected]','[email protected]','[email protected]']
ticketnumbers = ['1','2','3','4']
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
z = 0
while z < len(address):
mail = outlook.CreateItem(z)
z = z + 1
i = 0
while i < len(address):
mail.To = address[i]
mail.Subject = 'SUBJECT'
mail.Body = '''
Hello,
This is a test message!
Thanks,
JC
''' + ticketnumbers[i]
mail.Send()
i = i + 1
However I keep getting the following error:
![[1]: https://i.sstatic.net/FqVrw.png](https://i.sstatic.net/NxOkD.png)
How would I iterate through the address and the ticketnumbers lists so it's applied to each message individually?
Thanks!
You can directly add ; to mail. To object like below
mail. To = "[email protected];[email protected]"
You can put as many mails you want with ; in python
its works for mail.CC also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With