Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!bloom-beacon!GARP.MIT.EDU!henry
From: henry@GARP.MIT.EDU (Henry Mensch)
Newsgroups: comp.mail.mush
Subject: RMAIL to MUSH conversion
Message-ID: <8908171943.AA19211@GARP.MIT.EDU>
Date: 17 Aug 89 19:43:01 GMT
References: <1592@sunset.MATH.UCLA.EDU>
Sender: daemon@bloom-beacon.MIT.EDU
Reply-To: henry@GARP.MIT.EDU
Organization: The Internet
Lines: 49


this bit of e-lisp, which i got from robert krawitz 
should do the trick.  it could be just a tad cleverer, tho.

--- cut here ---

(defun rmail-convert-buffer-to-mail-file (file)
  "Convert current buffer to Mail format into a given filename"
  (interactive
   (list
    (read-file-name
     (concat "Output buffer to Unix mail file: (default "
	     (concat (file-name-nondirectory (buffer-file-name)) ".MAIL")
	     ") ")
     (file-name-directory (buffer-file-name))
     (concat (buffer-file-name) ".MAIL"))))
  (setq file (expand-file-name file))
  (let ((rmailbuf (current-buffer))
	(tembuf (get-buffer-create " rmail-output"))
	(case-fold-search t)
	(total rmail-total-messages)
	(msg rmail-current-message)
	(count 0)
	(str (concat "From " (user-real-login-name) "@" (system-name) "  "
		     (current-time-string) "\n")))
    (set-buffer tembuf)
    (delete-region (point-min) (point-max))
    (insert (concat "From " (user-real-login-name) "@" (system-name)))
    (set-buffer rmailbuf)
    (save-excursion
      (save-restriction
	(widen)
	(while (< count total)
	  (setq count (1+ count))
	  (let ((beg (rmail-msgbeg count))
		(end (rmail-msgend count)))
	    (goto-char beg)
	    (forward-line 2)
	    (search-forward "\n*** EOOH ***\n" end t)
	    (setq beg (point))
	    (goto-char end)
	    (forward-line 0)
	    (setq end (point))
	    (princ str tembuf)
	    (princ (buffer-substring beg end) tembuf)
	    (princ "\n" tembuf)))))
    (set-buffer tembuf)
    (append-to-file (point-min) (point-max) file)
    (kill-buffer tembuf)))