Content-Length: 305525 | pFad | http://github.com/urshala/google-cloud-python/commit/1fddfae6834920931bb4c655e0e71ced00fd5c36

4B Merge pull request #62 from blastter/master · urshala/google-cloud-python@1fddfae · GitHub
Skip to content

Commit 1fddfae

Browse files
authored
Merge pull request googleapis#62 from blastter/master
Sweet, I didn't know this was possible. Useful addition. Thanks.
2 parents 23eff38 + b3b3a2e commit 1fddfae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

O365/message.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class Message(object):
2525
getSenderName -- gets the name of the sender, if possible.
2626
getSubject -- gets the email's subject line.
2727
getBody -- gets contents of the body of the email.
28+
setFrom -- sets the email's sender in case username have permissions to send mail for
29+
other account.
2830
addRecipient -- adds a person to the recipient list.
2931
setRecipients -- sets the list of recipients.
3032
setSubject -- sets the subject line.
@@ -95,6 +97,8 @@ def sendMessage(self):
9597
data['Message']['Subject'] = self.json['Subject']
9698
data['Message']['Body']['Content'] = self.json['Body']['Content']
9799
data['Message']['Body']['ContentType'] = self.json['Body']['ContentType']
100+
if 'From' in self.json:
101+
data['Message']['From'] = self.json['From']
98102
data['Message']['ToRecipients'] = self.json['ToRecipients']
99103
data['Message']['CcRecipients'] = self.json['CcRecipients']
100104
data['Message']['BccRecipients'] = self.json['BccRecipients']
@@ -217,6 +221,15 @@ def addRecipient(self, address, name=None, r_type="To"):
217221
self.json[r_type + 'Recipients'].append(
218222
{'EmailAddress': {'Address': address, 'Name': name}})
219223

224+
def setFrom(self, address, name = None):
225+
'''
226+
Set custom sender through an other account, in case you have permissions to send as
227+
the other account.
228+
'''
229+
if name == None:
230+
name = address[:address.index('@')]
231+
self.json['From'] = {"EmailAddress":{"Address":address, "Name": name}}
232+
220233
def setSubject(self, val):
221234
'''Sets the subect line of the email.'''
222235
self.json['Subject'] = val

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/urshala/google-cloud-python/commit/1fddfae6834920931bb4c655e0e71ced00fd5c36

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy