Last active
April 5, 2024 16:53
-
-
Save exemplum100/1a671fa6ef3808c7221236640b70d995 to your computer and use it in GitHub Desktop.
Py+Outlook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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