Function: mml-generate-mime

mml-generate-mime is a byte-compiled function defined in mml.el.gz.

Signature

(mml-generate-mime &optional MULTIPART-TYPE CONTENT-TYPE)

Documentation

Generate a MIME message based on the current MML document.

MULTIPART-TYPE defaults to "mixed", but can also be "related" or "alternate".

If CONTENT-TYPE (and there's only one part), override the content type detected.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mml.el.gz
(defun mml-generate-mime (&optional multipart-type content-type)
  "Generate a MIME message based on the current MML document.
MULTIPART-TYPE defaults to \"mixed\", but can also
be \"related\" or \"alternate\".

If CONTENT-TYPE (and there's only one part), override the content
type detected."
  (let ((cont (mml-parse))
	(mml-multipart-number mml-multipart-number)
	(options message-options))
    (if (not cont)
	nil
      (when (and (consp (car cont))
		 (= (length cont) 1)
		 content-type)
        (when-let* ((spec (assq 'type (cdr (car cont)))))
	  (setcdr spec content-type)))
      (when (fboundp 'libxml-parse-html-region)
	(setq cont (mapcar #'mml-expand-all-html-into-multipart-related cont)))
      (prog1
	  (with-temp-buffer
	    (set-buffer-multibyte nil)
	    (setq message-options options)
	    (cond
	     ((and (consp (car cont))
		   (= (length cont) 1))
	      (mml-generate-mime-1 (car cont)))
	     ((eq (car cont) 'multipart)
	      (mml-generate-mime-1 cont))
	     (t
	      (mml-generate-mime-1
	       (nconc (list 'multipart (cons 'type (or multipart-type "mixed")))
		      cont))))
	    (setq options message-options)
	    (buffer-string))
	(setq message-options options)))))