Hello everyone,
When I try to run the below code, I receive the error:
An error occurred: (-2146959355, ‘Server execution failed’, None, None)
Can anyone help point me in the right direction?
import win32com.client
def create_outlook_email(recipient, subject, body):
try:
outlook = win32com.client.Dispatch(“Outlook.Application”)
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = subject
mail.Body = body
mail.Display() # Opens the email window
except Exception as e:
print(f"An error occurred: {e}")
if name == “main”:
recipient = input("Recipient email address: ")
subject = input("Email subject: ")
body = input("Email body: ")
create_outlook_email(recipient, subject, body)