- (save-excursion
- (save-restriction
- (mail-narrow-to-head)
- (goto-char (point-max)))
- (forward-line)
- (let ((text-start (point)) start-char end-char
- type file-name end-line result)
+ (let (ct ctl cte charset text-start start-char end-char
+ type file-name end-line result text-plain-type)
+ (save-excursion
+ (save-restriction
+ (mail-narrow-to-head)
+ (when (and (mail-fetch-field "mime-version")
+ (setq ct (mail-fetch-field "content-type")))
+ (setq cte (message-fetch-field "content-transfer-encoding" t)
+ ctl (ignore-errors (mail-header-parse-content-type ct))
+ charset (and ctl (mail-content-type-get ctl 'charset)))
+ (if (stringp cte)
+ (setq cte (intern (downcase (mail-header-remove-whitespace
+ (mail-header-remove-comments
+ cte)))))))
+ (goto-char (point-max)))
+ (forward-line)
+ (setq text-start (point)
+ text-plain-type (cons "text/plain"
+ (if charset
+ (list (cons 'charset charset)))))