That code I sent out yesterday was nfg.  If you applied it, use this:

(defun bbdb/vm-get-from (msg)
  (setq msg (vm-real-message-of msg))
  ;; Unfortunately the first arm of this if doesn't work because VM gloms
  ;; the various names and addresses of multi-recipient messages together
  ;; into one un-extractable mess.  We could use just the parts before the
  ;; first comma in each string, but that loses when a user has a comma in
  ;; their name ("Jr." etc).
;  (if (and (boundp 'vm-chop-full-name-function)
;          (eq vm-chop-full-name-function 'mail-extract-address-components))
;      ;; Good, VM is using mail-extr.el to do its parsing.  That means
;      ;; we can trust the junk in the pre-parsed message data.
;      (let ((n (vm-su-full-name msg))
;           (a (vm-su-from msg)))
;       ;; if logged in user sent this, use recipients.
;       (if (string-match (bbdb-user-mail-names) (or a ""))
;           (setq n (vm-su-to-names msg)
;                 a (vm-su-to msg)))
;       (if (= (length n) 0) (setq n nil))
;       (if (= (length a) 0) (setq a nil))
;       (if (equal n a) (setq n nil))
;       (list n a))
    ;; Bad, VM isn't using mail-extr, so we need to find the folder buffer
    ;; and parse out the From: field ourselves...
    (save-excursion
      (save-restriction
        ;; Select the buffer containing the message.
        ;; Needed to handle VM virtual folders.
        (set-buffer (vm-buffer-of msg))
        (widen)
        (narrow-to-region (vm-start-of msg) (vm-end-of msg))
        (let ((from (mail-fetch-field "from")))
          (if (or (null from)
                  (string-match (bbdb-user-mail-names)
                                ;; mail-strip-quoted-names is too broken!
                                ;;(mail-strip-quoted-names from)
                                (car (cdr (mail-extract-address-components
                                           from)))))
              ;; if logged in user sent this, use recipients.
              (setq from (or (mail-fetch-field "to") from)))
          from)))
;    )
  )


Reply via email to