From 9ecb82ccdbbcf1703aee556d0c59f3923a46ce31 Mon Sep 17 00:00:00 2001 From: tuomas56 Date: Sun, 6 Dec 2015 15:13:49 +0000 Subject: [PATCH 1/2] Add email address string support to setRecipients --- O365/message.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/O365/message.py b/O365/message.py index 95ea78caaa57..cf8540384bcd 100644 --- a/O365/message.py +++ b/O365/message.py @@ -159,8 +159,8 @@ def setRecipients(self,val): {"EmailAddress":{"Address":"recipient@example.com"}} with other options such ass "Name" with address. but at minimum it must have this. a list: this must to be a list of libraries formatted the way specified above, - or it can be a list of dictionary objects of type Contact. The method will sort - out the libraries from the contacts. + or it can be a list of dictionary objects of type Contact or it can be an email address as string. + The method will sort out the libraries from the contacts. a string: this is if you just want to throw an email address. a contact: type Contact from this dictionary. a group: type Group, which is a list of contacts. @@ -172,7 +172,10 @@ def setRecipients(self,val): for con in val: if isinstance(con,Contact): self.addRecipient(con) - else: + elif isinstance(con, str): + if '@' in con: + self.addRecipient(con) + elif isinstance(con, dict): self.json['ToRecipients'].append(con) elif isinstance(val,dict): self.json['ToRecipients'] = [val] From b65e277c7622f351d38730feb20c1a2fbed964f2 Mon Sep 17 00:00:00 2001 From: tuomas56 Date: Mon, 7 Dec 2015 09:50:13 +0000 Subject: [PATCH 2/2] Fix 80 char limit on docstring --- O365/message.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/O365/message.py b/O365/message.py index cf8540384bcd..e0490e6413f6 100644 --- a/O365/message.py +++ b/O365/message.py @@ -157,15 +157,17 @@ def setRecipients(self,val): val: the one argument this method takes can be very flexible. you can send: a dictionary: this must to be a dictionary formated as such: {"EmailAddress":{"Address":"recipient@example.com"}} - with other options such ass "Name" with address. but at minimum it must have this. - a list: this must to be a list of libraries formatted the way specified above, - or it can be a list of dictionary objects of type Contact or it can be an email address as string. - The method will sort out the libraries from the contacts. + with other options such ass "Name" with address. but at minimum + it must have this. + a list: this must to be a list of libraries formatted the way + specified above, or it can be a list of dictionary objects of + type Contact or it can be an email address as string. The + method will sort out the libraries from the contacts. a string: this is if you just want to throw an email address. a contact: type Contact from this dictionary. a group: type Group, which is a list of contacts. - For each of these argument types the appropriate action will be taken to fit them to the - needs of the library. + For each of these argument types the appropriate action will be taken + to fit them to the needs of the library. ''' self.json['ToRecipients'] = [] if isinstance(val,list):