Q: how can I attach multiple files to an outbound email with a minimum amount of fuss?

I'm using mu4e (which reuses message-mode, if that helps) to work with email. I often need to send emails with multiple attachments. mu4e uses mml-attach-file to handle attachments.

So far so good. However: it's an unpleasant task to use multiple attachments. mml-attach-file prompts for each file anew, which is time-consuming when the file is buried deep in a subtree.

It is almost always the case that, when I need to attach multiple files, they are all in the same directory. In this situation, how can I convince mml-attach-file to detect an attachment in the existing message buffer and, if it finds one, use that attachment's directory as the default for the next file I attempt to attach?

NB: If one digs into the source code, mml-attach-file relies on mml-minibuffer-read-file, which in turn uses either mml-default-directory or default-directory.

PS: I'm aware of How to attach multiple files in message-mode, but there's no answer there.

  • 1
    (1) Do you like the idea of popping open a dired-mode buffer from the the email message in recursive-edit, then marking the files in dired-mode and exiting recursive-edit while throwing the result of dired-get-marked-files, which is then used by a mapcar to attach each file in one fell swoop? (2) Or, do you like the idea of starting in dired-mode, marking your files, and then pressing an email generate button that creates the message and attaches all marked files using dired-get-marked-files and a mapcar to run down the list and attach all files in one fell swoop?
    – lawlist
    Commented Aug 11, 2015 at 16:23
  • @lawlist: I've got the dired version going from the mu4e manual, but I'm looking for a way to do this without going through dired.
    – Dan
    Commented Aug 11, 2015 at 17:47
  • I'm a little surprised to see "there's no answer" as an argument for asking a duplicate question. However since your question attracted a valid answer, I guess I'm happy.
    – YoungFrog
    Commented Aug 12, 2015 at 10:18

5 Answers 5


I can only suggest a solution for gnus and dired but it is at least easier as lawlist suggested. Open the directory in dired with C-x 4 d and type M-x turn-on-gnus-dired-mode. Then mark the required files and type C-c RET C-a. That's it and the files can be attached to an already opened or a new message buffer (I'm not sure if this works for other MUAs as well)!

  • IIUC the OP doesn't want to use dired, but if you'd answer my own question (at emacs.stackexchange.com/questions/14514/…) I'd be very happy to accept it there.
    – YoungFrog
    Commented Aug 12, 2015 at 10:41
  • @YoungFrog: He should get used to dired as soon as possible ;-) and thanks for the hint, answered your question. Commented Aug 12, 2015 at 15:45
  • @Dieter.Wilhelm: I am using dired, but also want to have the specific functionality I mentioned in the question. I'll leave the question open for a bit longer to see if anyone has any ideas on it.
    – Dan
    Commented Aug 12, 2015 at 18:33

open up a GUI file browser and drag the files to your emacs draft window/buffer


I like to use helm-find-files for this. You navigate to where the files are, mark the ones you want with C-spc, and attach them with C-c C-a (or press tab and find the attach files to email action).

The ivy equivalent of this is counsel-find-file. First, add this action to it:

 '(("a" (lambda (x)
      (unless (memq major-mode '(mu4e-compose-mode message-mode))
      (mml-attach-file x)) "Attach to email")))

In this case, you navigate to the files, and type C-M-o then a, and continue to the next file. I don't like this as much as marking them all at once in helm, but I don't often attach many files.


Old post but I got here having the same basic desire and rolled my own snippet to solve it. For others coming here this might be something suitable.

(defun compose-attach-marked-files ()
  "Compose mail and attach all the marked files from a dired buffer."
  (let ((files (dired-get-marked-files)))
    (compose-mail nil nil nil t)
    (dolist (file files)
          (if (file-regular-p file)
              (mml-attach-file file
                               (mm-default-file-encoding file)
                               nil "attachment")
            (message "skipping non-regular file %s" file)))))

This code means to attach all marked dired "normal" files to a new message buffer if none exist or add attachments to an existing message buffer. Works perfect here.


Old post, but I want to propose an improvement on @Tompa answer. Here is how to attach multiple files to an existing email:

  1. I open a dired buffer and select the files I want to attach
  2. I run the following function:
   (defun attach-marked-files (buffer)
      "Attach all marked files to BUFFER"
      (interactive "BAttach to buffer: ")
      (let ((files (dired-get-marked-files)))
        (with-current-buffer (get-buffer buffer)
          (dolist (file files)
            (if (file-regular-p file)
              (mml-attach-file file
                (mm-default-file-encoding file)
                nil "attachment")
              (message "skipping non-regular file %s" file)))))
      (switch-to-buffer buffer))
  1. The function will interactively ask me to which buffer I want to attach the files, and it's done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.