28 June 2024

How to use Outlook to access your Google Workspace email?

https://support.google.com/a/users/answer/171710#different

How to send Outlook email with Python

> pip install pywin32

import win32com.client

inbox = win32com.client.gencache.EnsureDispatch("Outlook.Application").GetNamespace("MAPI")
# print(dir(inbox))
inbox = win32com.client.Dispatch("Outlook.Application")
# print(dir(inbox))

mail = inbox.CreateItem(0x0)
mail.To = "testTo@test.com"
mail.CC = "testcc@test.com"
mail.BCC = "testcc@test.com" mail.Subject = "Send TEST" mail.Body = "This is the body" mail.Attachments.Add(u"path to attachment") mail.Send()
print('Email sent successfully.')


Remember that in the attachment to use escape characters on windows systems i.e.

c:\users\me  should be  c:\\users\\me