info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking attachments are actually attached


From: François Fleuret
Subject: Checking attachments are actually attached
Date: Sat, 08 Apr 2006 12:34:21 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]