I do something similar to change identity and/or input language based on addressee. I just put it in a hook (add-hook 'message-setup-hook 'rjn-change-stuff-by-addressee t)
and that works for me; the appropriate identity gets chosen via gnus-alias-use-identity when the message reply is set up. My complete code is this. It is not the same as you ask but easily modified. You'd only need the upper half. (defun rjn-change-stuff-by-addressee () (interactive) (let ((addressee (message-fetch-field "To")) netaddr person smtppref) (if addressee (setq netaddr (cadr (mail-extract-address-components addressee)))) (if netaddr (setq person (car (bbdb-search (bbdb-records) :mail netaddr)))) (if person (setq smtppref (bbdb-record-field person 'smtp))) (if smtppref (gnus-alias-use-identity smtppref)) ) (let ((addressee (message-fetch-field "To")) netaddr person langpref) (if addressee (setq netaddr (cadr (mail-extract-address-components addressee)))) (if netaddr (progn (setq person (car (bbdb-search (bbdb-records) :mail netaddr))))) (if person (setq langpref (bbdb-record-field person 'language))) (if langpref (set-input-method langpref))) ) -- Bob Newell Honolulu, Hawai`i - Via GNU/Linux/Emacs/Gnus/BBDB