Function: mml-attach-file
mml-attach-file is an autoloaded, interactive and byte-compiled
function defined in mml.el.gz.
Signature
(mml-attach-file FILE &optional TYPE DESCRIPTION DISPOSITION)
Documentation
Attach a file to the outgoing MIME message.
The file is not inserted or encoded until you send the message with
M-x message-send-and-exit (message-send-and-exit) or M-x message-send (message-send) in Message mode,
or M-x mail-send-and-exit (mail-send-and-exit) or M-x mail-send (mail-send) in Mail mode.
FILE is the name of the file to attach. TYPE is its content-type, a string of the form "type/subtype". DESCRIPTION is a one-line description of the attachment. The DISPOSITION specifies how the attachment is intended to be displayed. It can be either "inline" (displayed automatically within the message body) or "attachment" (separate from the body).
Also see the mml-attach-file-at-the-end variable.
If given a prefix interactively, no prompting will be done for the TYPE, DESCRIPTION or DISPOSITION values. Instead defaults will be computed and used.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/mml.el.gz
;;;###autoload
(defun mml-attach-file (file &optional type description disposition)
"Attach a file to the outgoing MIME message.
The file is not inserted or encoded until you send the message with
`\\[message-send-and-exit]' or `\\[message-send]' in Message mode,
or `\\[mail-send-and-exit]' or `\\[mail-send]' in Mail mode.
FILE is the name of the file to attach. TYPE is its
content-type, a string of the form \"type/subtype\". DESCRIPTION
is a one-line description of the attachment. The DISPOSITION
specifies how the attachment is intended to be displayed. It can
be either \"inline\" (displayed automatically within the message
body) or \"attachment\" (separate from the body).
Also see the `mml-attach-file-at-the-end' variable.
If given a prefix interactively, no prompting will be done for
the TYPE, DESCRIPTION or DISPOSITION values. Instead defaults
will be computed and used."
(interactive
(let* ((file (mml-minibuffer-read-file "Attach file: "))
(type (if current-prefix-arg
(or (mm-default-file-type file)
"application/octet-stream")
(mml-minibuffer-read-type file)))
(description (if current-prefix-arg
nil
(mml-minibuffer-read-description)))
(disposition (if current-prefix-arg
(mml-content-disposition type file)
(mml-minibuffer-read-disposition type nil file))))
(list file type description disposition)))
;; If in the message header, attach at the end and leave point unchanged.
(let ((at-end (and (or (not (message-in-body-p))
mml-attach-file-at-the-end)
(point))))
(when at-end
(goto-char (point-max)))
(mml-insert-empty-tag 'part
'type type
;; icicles redefines read-file-name and returns a
;; string with text properties :-/
'filename (substring-no-properties file)
'disposition (or disposition "attachment")
'description description)
;; When using Mail mode, make sure it does the mime encoding
;; when you send the message.
(unless (eq mail-user-agent 'message-user-agent)
(setq mail-encode-mml t))
(when at-end
(unless (pos-visible-in-window-p)
(message "The file \"%s\" has been attached at the end of the message"
(file-name-nondirectory file)))
(goto-char at-end))))