On Wed, Jul 08 2015, Henrik Frisk <
fri...@gmail.com> wrote:
> Hi,
>
> After having had a working setup with multiple accounts but just one SMTP
> server it was necessary for me to set mu4e up with multiple accounts and
> multiple SMTP servers. I followed the instructions here:
>
>
http://www.djcbsoftware.nl/code/mu/mu4e/Multiple-accounts.html
>
> which appears to be working fine, except for old messages which I cannot
> reply to since they lack the necessary maildir folder. Could someone here
> help me make a small addition so that instead of the error message I get to
> choose the account to send from, as if it was a new message?
Well, since I originally wrote that code, I might as well volunteer. ;-)
> I think this would be usful for many!
Actually, it never occurred to me that someone might want to reply to a
message that's not in an account folder. I do put old messages in an
Archive folder that is not linked to any account, but those messages are
so old I never even look at them, let alone reply to them...
Anyway, the following seems to work:
```
(defun my-mu4e-set-account ()
"Set the account for composing a message."
(let* ((accounts (mapcar #'car my-mu4e-account-alist))
(account
(or (and mu4e-compose-parent-message
(let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
(string-match "/\\(.*?\\)/" maildir)
(car (member (match-string 1 maildir) accounts))))
(completing-read (format "Compose with account: (%s) "
(mapconcat #'identity accounts "/"))
accounts
nil t nil nil (car accounts))))
(account-vars (cdr (assoc account my-mu4e-account-alist))))
(if account-vars
(mapc #'(lambda (var)
(set (car var) (cadr var)))
account-vars)
(error "No email account found"))))
```
Let me know if you run into any trouble.
--
Joost Kremers
Life has its moments