The solution given by @tmalsburg worked for me until I switched to the gnus-based message view, which is now the default.
Below is my attempt to adapt this solution to the new view mode. Note that I do not know lisp and reached that solution by trial and error. It works for me, but you should be careful when copying it.
(defun my-mime-part-filename (num)
"Filename of MIME part numbered num in gnus-article-mode."
;; Check whether the specified part exists.
(when (> num (length gnus-article-mime-handle-alist))
(error "No such part"))
;; Move point to MIME part
(when (gnus-article-goto-part num)
;; Get handle for MIME part at point
(let ((handle (get-text-property (point) 'gnus-data)))
;; Return file name of handle
(defun my-delete-attachment (num)
"Remove email attachment from mu4e using altermime."
(let* ((path (mu4e-message-field (mu4e-message-at-point) :path))
(filename (my-mime-part-filename num))
(cmd (format "altermime --input='%s' --remove='%s'" path filename)))
(when (and filename
(format "Remove '%s'?" filename)))
(defun my-delete-all-attachments (msg)
"Remove all email attachments in mu4e using altermime."
(let* ((path (mu4e-message-field msg :path))
(subject (mu4e-message-field msg :subject))
(cmd (format "altermime --input='%s' --removeall" path)))
(format "Remove all attachments from '%s'?" subject))
'("Delete-all-attachments" . my-delete-all-attachments))
As I said, I do not know lisp (in any flavour) and so there are probably multiple issues with this code. Any suggestion to improve it is more than welcome. In particular, I feel that the line
(filename (my-mime-part-filename num)) in
my-delete-attachment could (should?) be
(filename (gnus-article-part-wrapper num 'mm-handle-filename)), but that last expression returns