Dear all,

I wrote this, which may be of interest for others:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Checks that the mail contains an attached file if the body refers
;; to such an attachment. The idea comes from
;; http://home.cc.gatech.edu/eaganj/MailApp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defcustom check-no-missing-attachment-regexp "attach"
  "*A mail whose body matches this regular expression should contain
an attachment")

(defun contains-attachment (l)
  (and l (or (and
              (eq (car (car l)) 'part)
              (string= "attachment" (cdr (assoc 'disposition (cdr (car l))))))
             (contains-attachment (cdr l)))))

(defun check-no-missing-attachment ()
  "Checks the mail contains an attached file if the body refers to such an 
attachment"
  (message-goto-body)
  (and (re-search-forward check-no-missing-attachment-regexp nil t)
       (not (contains-attachment (mml-parse)))
       (not (y-or-n-p "An attachment seems to be missing, send message ? "))
       (error "You refer to an unexisting attachment.")))

(add-hook 'message-send-hook 'check-no-missing-attachment)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Comments are of course welcome.

Cheers,

-- 
François Fleuret                          http://cvlab.epfl.ch/~fleuret
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
http://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to