-
-
Save garymanley/df73d5dbd007c7daf0fdd1e8eda24cc1 to your computer and use it in GitHub Desktop.
OutlookBasicSend.py
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Dec 30 16:56:13 2017 | |
@author: garym | |
""" | |
#import win32com.client | |
from win32com.client import Dispatch | |
import datetime | |
import win32com.client | |
######################################## | |
### Set up file to attach | |
######################################## | |
filename = r'C:\Users\garym\Documents\New folder (2)\CV.docx' | |
######################################## | |
## Connect to Outlook inbox | |
######################################### | |
outlook = Dispatch("Outlook.Application").GetNamespace("MAPI") | |
# "6" refers to the index of a folder. 6 is the inbox | |
inbox = outlook.GetDefaultFolder("6") | |
### all inbox for today after 7am | |
##################### | |
### Craete new Email | |
##################### | |
const=win32com.client.constants | |
olMailItem = 0x0 | |
obj = win32com.client.Dispatch("Outlook.Application") | |
newMail = obj.CreateItem(olMailItem) | |
################################## | |
##Mail content | |
################################## | |
newMail.Subject = "Hello World - " + str(datetime.datetime.today().strftime('%d/%m/%Y')) | |
newMail.Attachments.Add(filename) | |
newMail.Body = "Hello World" | |
################################## | |
### Set recipients to maillist | |
################################# | |
newMail.To = 'my@email.com' | |
newMail.CC = 'my@email.com' | |
################################ | |
## Show E-mail (change to send to send) | |
################################ | |
newMail.display() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment