Many functions in mu4e deal with message plists (property
lists). They contain information about messages, such as sender and
recipient, subject, date and so on. To deal with these plists, there are
a number of mu4e-message- functions (in mu4e-message.el),
such as mu4e-message-field and mu4e-message-at-point, and
a shortcut to combine the two, mu4e-message-field-at-point.
For example, to get the subject of the message at point, in either the headers view or the message view, you could write:
(mu4e-message-field (mu4e-message-at-point) :subject)
Note that:
(:name NAME :email EMAIL); :name may be missing. So, for example:
(mu4e-message-field some-msg :to) ;; => ((:name "Jack" :email "jack@example.com") (:email "foo@example.com"))
If you are only looking for a match in this list (e.g., “Is Jack one of the
recipients of the message?”), there is a convenience function
mu4e-contact-matches-p to make this easy.
Note that in headers-mode, you only have access to a reduced message
plist, without the information about the message-body or mime-parts;
mu4e does this for performance reasons. And even in view-mode, you
do not have access to arbitrary message-headers.
However, it is possible to get the information indirectly, using the
raw-message and some third-party tool like procmail’s formail:
(defun my-mu4e-any-message-field-at-point (hdr)
"Get an arbitrary header HDR at point in a hacky way.
Requires the 'formail' tool from procmail."
(replace-regexp-in-string "\n$" ""
(shell-command-to-string
(concat "formail -x " hdr " -c < "
(shell-quote-argument (mu4e-message-field-at-point :path))))))