diff options
Diffstat (limited to 'python/exchange.py')
| -rw-r--r-- | python/exchange.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/python/exchange.py b/python/exchange.py index d341cacb..18c88669 100644 --- a/python/exchange.py +++ b/python/exchange.py @@ -11,19 +11,28 @@ def get_account(email_address): return Account(primary_smtp_address=email_address, config=config, autodiscover=False, access_type=DELEGATE) +class ExchangeMessage: + _account = get_account("ghorel@lmcg.com") -def get_msgs(account=None, email_address='ghorel@lmcg.com', count=None, - path=['GS', 'Swaptions'], subject_filter=None): - if account is None: - account = get_account(email_address) - folder = account.inbox - for p in path: - folder /= p - if subject_filter is not None: - folder = folder.filter(subject__contains=subject_filter) - if count: - for msg in folder.all().order_by('-datetime_sent')[:count]: - yield msg - else: - for msg in folder.all().order_by('-datetime_sent'): - yield msg + def get_msgs(self, count=None, + path=['GS', 'Swaptions'], **filters): + folder = self._account.inbox + for p in path: + folder /= p + folder = folder.filter(**filters) + if count: + for msg in folder.all().order_by('-datetime_sent')[:count]: + yield msg + else: + for msg in folder.all().order_by('-datetime_sent'): + yield msg + + def send_email(self, subject, body, to_recipients, + cc_recipients): + m = Message(account=self._account, + folder=self._account.sent, + subject=subject, + body=body, + to_recipients=to_recipients, + cc_recipients=cc_recipients) + m.send_and_save() |
