Getting all attachments when using mu4e-headers-for-each?

14 views
Skip to first unread message

Hippo Man

unread,
Nov 25, 2016, 6:11:26 PM11/25/16
to mu-discuss
In the headers buffer, I want to loop through a group of messages whose headers have been selected within a region, and I want to access all the attachments from any messages that contain them.

I am able to successfully loop through the messages, but the :parts attribute is missing for each of these messages. What do I need to do in order to get the message parts by means of the following function? ...

(defun process-all-attachments ()
 
(interactive)
 
(let ((start (if (region-active-p) (region-beginning) (point-min)))
       
(end (if (region-active-p) (region-end) (point-max))))
   
(save-excursion
     
(save-restriction
       
(narrow-to-region start end)
       
(mu4e-headers-for-each
         
(lambda (msg)
         
(let ((flags (mu4e-message-field msg :flags)))
             
(when (member 'attach flags)
               
;; WHAT DO I DO HERE TO GET ALL OF THE MESSAGE PARTS???
                ))))))))

Thank you in advance.
.

Dirk-Jan C. Binnema

unread,
Nov 26, 2016, 5:18:47 AM11/26/16
to mu-di...@googlegroups.com

On Saturday Nov 26 2016, Hippo Man wrote:

> In the headers buffer, I want to loop through a group of messages whose
> headers have been selected within a region, and I want to access all the
> attachments from any messages that contain them.
>
> I am able to successfully loop through the messages, but the *:parts*
> attribute is missing for each of these messages. What do I need to do in
> order to get the message parts by means of the following function? ...
>
> (defun process-all-attachments ()
> (interactive)
> (let ((start (if (region-active-p) (region-beginning) (point-min)))
> (end (if (region-active-p) (region-end) (point-max))))
> (save-excursion
> (save-restriction
> (narrow-to-region start end)
> (mu4e-headers-for-each
> (lambda (msg)
> (let ((flags (mu4e-message-field msg :flags)))
> (when (member 'attach flags)
> *;; WHAT DO I DO HERE TO GET ALL OF THE MESSAGE PARTS???*
> ))))))))
>

In headers-mode, mu4e uses reduced message-objects (for performance
reasons), which don't include e.g. message bodies, mime-parts etc.

If you want to, say, extract the attachments for such messages, one
possibility would be to use the :path field and shell out to "mu
extract".

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Hippo Man

unread,
Nov 26, 2016, 9:31:49 AM11/26/16
to mu-discuss
Oh, OK. Thank you. I will do it that way.

Reply all
Reply to author
Forward
0 new messages