Here is my current code for automatic fcc via the `auto-fcc' bbdb field.
It now happens both at mail-setup time, so it works in replies and such,
and at mail-abbrev expansion time.


(defun bbdb/auto-fcc-by-net (net)
  (let ((folder (bbdb-record-getprop (bbdb-search-simple nil net)
                                     'auto-fcc)))
    (if folder
        (mail-fcc (expand-file-name folder vm-folder-directory)))))

(add-hook 'after-load-alist
          '("bbdb-com"
            (insert-hooks 'bbdb-mail-abbrev-expand-hook nil
                          'after-bbdb-mail-abbrev-expand-hook)))
(add-hook 'after-bbdb-mail-abbrev-expand-hook 'bbdb/mail-abbrev-auto-fcc)
(defun bbdb/mail-abbrev-auto-fcc ()
  (mapcar 'bbdb/auto-fcc-by-net records))

(add-hook 'mail-setup-hook 'bbdb/mail-auto-fcc)
(defun bbdb/mail-auto-fcc ()
  (let ((to (mail-fetch-field "to" nil t)))
    (if to
        (mapcar 'bbdb/auto-fcc-by-net (rfc822-addresses to)))))

Reply via email to