Here's something I hacked up the other day from a similar hack for vm.
When you hit "o" in Rmail it will try to find a mail-folder field
associated with the sender (or receiver if you sent the mail).
(defun rmail-bbdb-guess-folder ()
"Try to find a mail-folder in the BBDB."
(let* ((record (bbdb/rmail-update-record))
(folder (and record (bbdb-record-getprop record 'mail-folder))))
(if folder
(expand-file-name folder rmail-secondary-file-directory))))
To set it up put
'("." . (rmail-bbdb-guess-folder))
somewhere in rmail-output-file-alist (I put it at the beginning), set
rmail-secondary-file-directory appropriately, and it should work
nicely.
My mail-folder fields tend to look like "people/Fred.Nurks" or
"emacs/bbdb"...
peace & happiness,
martin