diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-25 14:52:20 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-25 16:43:37 +0000 |
commit | 81e35d8f25d1d50f7351e9f661d3e825c058836a (patch) | |
tree | ec128c7bcfbd46fe93f134b92d27ecdd5b6e10f0 /alot/commands/envelope.py | |
parent | 4ff6eebcce7eecb1d9730744bf17b23837db6260 (diff) |
add save command for envelope
this saves the current envelope as mail to the draft mailbox
of the account read from the From-header or your default one.
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r-- | alot/commands/envelope.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 5e54b63f..e35ce7c0 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -70,6 +70,33 @@ class RefineCommand(Command): ui.apply_command(globals.PromptCommand(cmdstring)) +@registerCommand(MODE, 'save') +class SendCommand(Command): + """save draft""" + def apply(self, ui): + envelope = ui.current_buffer.envelope + + # determine account to use + sname, saddr = email.Utils.parseaddr(envelope.get('From')) + account = ui.accountman.get_account_by_address(saddr) + if account == None: + if not ui.accountman.get_accounts(): + ui.notify('no accounts set.', priority='error') + return + else: + account = ui.accountman.get_accounts()[0] + + if account.draft_box == None: + ui.notify('abort: account <%s> has no draft_box set.' % saddr, + priority='error') + return + + mail = envelope.construct_mail() + account.store_draft_mail(mail) + ui.apply_command(commands.globals.BufferCloseCommand()) + ui.notify('draft saved successfully') + + @registerCommand(MODE, 'send') class SendCommand(Command): """send mail""" |