Emailing an alert before an event scheduled in Emacs org system.
My goal is to get emacs to send me a text message before an appointment, but I only want one text message, not a message every two minutes. I cobbled together this "check-sent-messages" function that returns true if a message has not been sent before and false (nil) otherwise.
The first time a message is checked, this function looks for a matching message in a list of previously checked messages. If it doesn't find the message, it adds this one to the list and returns true (t). If it finds the message, it returns false. The list only lasts as long as emacs (or the emacs server) is running, which is long enough for my needs.
(defun check-sent-messages (mesg)
(interactive)
(setq ; I tried using "let" but I was having trouble with it
listlen_var_bk (length sent-message-list))
(add-to-list 'sent-message-list mesg)
(cond ((equal listlen_var_bk (length sent-message-list)) nil)
(t t)
)
)
This function sends a message prior to an event scheduled in Emacs' org mode. It only sends the message if it hasn't been sent before (it uses the check-sent-messages function to figure out if it's been sent). I'm sending it to a canned, fixed address because I always want the messages to go to the same place and I'm not that concerned about making this function more general purpose. I can send the messages to my phone's text message address and get a message anywhere, which is what I need.
;; This is the function to call to send mail when an appointment is due: appt-disp-window-function.
(defun appt-email-send (min-to-app new-time appt-msg)
"Send an appointment reminder email due in MIN-TO-APP (a string) minutes.
NEW-TIME is a string giving the date and time of the appointment (or any other string)."
(setq email_body
(format " Appointment %s. Time: %s."
(if (string-equal "0" min-to-app) "now"
(format "in %s minute%s" min-to-app
(if (string-equal "1" min-to-app) "" "s")))
new-time))
(if (check-sent-messages appt-msg) (my-message-mail-fn "recipient@email.com" appt-msg email_body))
)
My goal is to get emacs to send me a text message before an appointment, but I only want one text message, not a message every two minutes. I cobbled together this "check-sent-messages" function that returns true if a message has not been sent before and false (nil) otherwise.
The first time a message is checked, this function looks for a matching message in a list of previously checked messages. If it doesn't find the message, it adds this one to the list and returns true (t). If it finds the message, it returns false. The list only lasts as long as emacs (or the emacs server) is running, which is long enough for my needs.
(defun check-sent-messages (mesg)
(interactive)
(setq ; I tried using "let" but I was having trouble with it
listlen_var_bk (length sent-message-list))
(add-to-list 'sent-message-list mesg)
(cond ((equal listlen_var_bk (length sent-message-list)) nil)
(t t)
)
)
This function sends a message prior to an event scheduled in Emacs' org mode. It only sends the message if it hasn't been sent before (it uses the check-sent-messages function to figure out if it's been sent). I'm sending it to a canned, fixed address because I always want the messages to go to the same place and I'm not that concerned about making this function more general purpose. I can send the messages to my phone's text message address and get a message anywhere, which is what I need.
;; This is the function to call to send mail when an appointment is due: appt-disp-window-function.
(defun appt-email-send (min-to-app new-time appt-msg)
"Send an appointment reminder email due in MIN-TO-APP (a string) minutes.
NEW-TIME is a string giving the date and time of the appointment (or any other string)."
(setq email_body
(format " Appointment %s. Time: %s."
(if (string-equal "0" min-to-app) "now"
(format "in %s minute%s" min-to-app
(if (string-equal "1" min-to-app) "" "s")))
new-time))
(if (check-sent-messages appt-msg) (my-message-mail-fn "recipient@email.com" appt-msg email_body))
)
0 Comments:
Post a Comment
<< Home