3
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.SentOnBehalfOfName = 'EMAIL'
mail.To = 'EMAIL'
mail.Subject = 'Message subject'
mail.Body = 'Message body'
mail.HTMLBody = 'HTML Message body' #this field is optional
mail.display(True)

Using the above code I am able to send mails via outlook using Python. It opens a email window on which I can click on Send button to finally send the email.

My question is, can I track if the email was actually sent or someone just closed the outlook window? Just to make sure the code can keep a track of mails sent or not sent.

martineau
  • 119,623
  • 25
  • 170
  • 301
gaurav2141
  • 130
  • 8
  • Even if the email was sent, you can never confirm it was received unless you put a link into it that needs to be clicked. If you want to send emails, do it directly with the mail server, not via a client software like Outlook. – Thomas Weller Oct 22 '21 at 17:14
  • You can write an event handler for the MailItem Send event, which gets fired just before the item is sent (giving a chance to cancel the send). – DS_London Oct 26 '21 at 06:41

0 Answers0