Skip to content

Instantly share code, notes, and snippets.

@exemplum100
Last active April 5, 2024 16:53
Show Gist options
  • Save exemplum100/1a671fa6ef3808c7221236640b70d995 to your computer and use it in GitHub Desktop.
Save exemplum100/1a671fa6ef3808c7221236640b70d995 to your computer and use it in GitHub Desktop.
Py+Outlook
import os
import win32com.client as win32
olApp = win32.Dispatch('Outlook.Application')
olNS = olApp.GetNameSpace('MAPI') # NameSpaces need for attchm
mailItem = olApp.CreateItem(0)
mailItem.Subject = 'Dummy Email2'
mailItem.BodyFormat = 1
mailItem.Body = "Hello World"
mailItem.To = '@gmail.com'
mailItem.Attachments.Add(os.path.join(os.getcwd(), 'test.txt')) #workfolder
#mailItem.Display()
#mailItem.Save()
mailItem.Send()
# Change secure app settings in outlook to send without pop-notify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment