| 1 |
"""
|
| 2 |
OutlookLib
|
| 3 |
|
| 4 |
Created by
|
| 5 |
Emanuel Borges
|
| 6 |
03.15.2017
|
| 7 |
|
| 8 |
Just an Outlook library to make automating Outlook a bit faster for me.
|
| 9 |
|
| 10 |
"""
|
| 11 |
|
| 12 |
from win32com.client import constants as c
|
| 13 |
import win32com.client
|
| 14 |
|
| 15 |
class OutlookConnection:
|
| 16 |
def __init__(self):
|
| 17 |
self.outlookApp = win32com.client.Dispatch("Outlook.Application")
|
| 18 |
self.outlookEmailItem = 0x0
|
| 19 |
|
| 20 |
def DraftEmail(self, emailTO, emailCC, emailSubject, emailBody, emailAttachment = None, bodyType = 'HTML'):
|
| 21 |
"""Easy way to draft an email and wont send"""
|
| 22 |
newEmailMessage = self.outlookApp.CreateItem(self.outlookEmailItem)
|
| 23 |
newEmailMessage.Subject = emailSubject
|
| 24 |
newEmailMessage.GetInspector
|
| 25 |
if bodyType == 'HTML':
|
| 26 |
newEmailMessage.HtmlBody = emailBody
|
| 27 |
else:
|
| 28 |
newEmailMessage.Body = emailBody
|
| 29 |
newEmailMessage.To = emailTO
|
| 30 |
newEmailMessage.Cc = emailCC
|
| 31 |
if emailAttachment:
|
| 32 |
newEmailMessage.Attachments.Add(Source=emailAttachment)
|
| 33 |
newEmailMessage.Display()
|
| 34 |
#newEmailMessage.send() |