Hi, This is a function to add mail addresses to BBDB when sending mail. Adding it to mail-send-hook should trigger it when the mail is sent:
(add-hook 'mail-send-hook 'bbdb/sendmail-update-records) The function returns a list of the records that were added. It does not use the window-popup like bbdb/rmail-update-records. Perhaps it should. There is no cache. As for the buffer, it is assumed that if the current buffer is in mail-mode, the function can go ahead, otherwise it switches to the "*mail*" buffer. (defun bbdb/sendmail-update-records (&optional offer-to-create) "Returns the new records corresponding to the current *mail* message, creating or modifying it as necessary. A record will be created if `bbdb/mail-auto-create-p' is non-nil, or if OFFER-TO-CREATE is true and the user confirms the creation." (unless (eq major-mode 'mail-mode) (set-buffer "*mail*")) (save-restriction (save-excursion (narrow-to-region (point-min) (mail-header-end)) (let ((addrs (split-string (mapconcat 'identity (list (mail-fetch-field "to" nil t) (mail-fetch-field "cc" nil t) (mail-fetch-field "bcc" nil t)) ", ") ",[[:space:]]*" t)) records) (dolist (addr addrs records) (let ((rec (bbdb-annotate-message-sender addr t (or (bbdb-invoke-hook-for-value bbdb/mail-auto-create-p) offer-to-create) offer-to-create))) (when rec (push rec records)))))))) F ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ bbdb-info@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bbdb-info BBDB Home Page: http://bbdb.sourceforge.net/