-(defun wl-summary-resend-message (address)
- "Resend the current message to ADDRESS."
- (interactive "sResend message to: ")
- (if (or (null address) (string-match "^[ \t]*$" address))
- (message "No address specified.")
- (message "Resending message to %s..." address)
- (save-excursion
- (let ((original (wl-summary-get-original-buffer)))
- ;; We first set up a normal mail buffer.
- (set-buffer (get-buffer-create " *wl-draft-resend*"))
- (buffer-disable-undo (current-buffer))
- (erase-buffer)
- (setq wl-sent-message-via nil)
- ;; Insert our usual headers.
- (wl-draft-insert-from-field)
- (wl-draft-insert-date-field)
- (insert "to: " address "\n")
- (goto-char (point-min))
- ;; Rename them all to "Resent-*".
- (while (re-search-forward "^[A-Za-z]" nil t)
- (forward-char -1)
- (insert "Resent-"))
- (widen)
- (forward-line)
- (delete-region (point) (point-max))
- (let ((beg (point)))
- ;; Insert the message to be resent.
- (insert-buffer-substring original)
- (goto-char (point-min))
- (search-forward "\n\n")
- (forward-char -1)
- (save-restriction
- (narrow-to-region beg (point))
- (wl-draft-delete-fields wl-ignored-resent-headers)
- (goto-char (point-max)))
- (insert mail-header-separator)
- ;; Rename all old ("Previous-")Resent headers.
- (while (re-search-backward "^\\(Previous-\\)*Resent-" beg t)
- (beginning-of-line)
- (insert "Previous-"))
- ;; Quote any "From " lines at the beginning.
- (goto-char beg)
- (when (looking-at "From ")
- (replace-match "X-From-Line: ")))
- ;; Send it.
- (wl-draft-dispatch-message)
- (kill-buffer (current-buffer)))
- (message "Resending message to %s...done" address))))
-