ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Tool_Box/OutlookLib.py
Revision: 637
Committed: Wed Mar 28 20:17:13 2018 UTC (8 years ago) by nino.borges
Content type: text/x-python
File size: 1312 byte(s)
Log Message:
Updated to allow saving or displaying.

File Contents

# User Rev Content
1 nino.borges 632 """
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 nino.borges 637 def DraftEmail(self, emailTO, emailCC, emailSubject, emailBody, emailAttachment = None, bodyType = 'HTML', finishType = 'Display', savePath = None):
21     """Easy way to draft an email and wont send if you allow finishType as Display. Can be changed to OFT, to save it instead."""
22 nino.borges 632 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 nino.borges 637 if finishType == 'OFT':
34     newEmailMessage.SaveAs(savePath)
35     else:
36     newEmailMessage.Display()
37 nino.borges 632 #newEmailMessage.send()