1

In office, I need to send one mail to boss every day, every week, and every month. Usually I composed those mails every afternoon and leave them in a * send mail * buffer, and send them when I prepare to go home. Sometimes I forget to send the mail even if I finished composing them. The next day I found the * send mail * buffer and BANG I felt very upset.

AFAIK, there are several ways in Emacs to compose a mail and send a mail. Are there any methods to schedule a specific mail sending in a specific time, for example, at 6:00pm later that day? If not, how to write a function so that I can run the function for a specific mail and let them be sent at the given time?


EDITED:

This question is something different from the similar Gnus question. I want to set a different schedule for each mail to be sent.


Here I provide some pseudocode that come to my mind, but this does not works. Can anyone give me some advices? Thank you!

;; one pseudocode:
(require 'midnight)
(defun schedule-send-mail-in-current-buffer ()
  (interactive ???)
  (prompt-and-get buffer-name)
  (prompt-and-get send-time) ;; like 19:00pm
  (rename-this-buffer buffer-name)
  (bury-buffer (get-buffer buffer-name))
  ;; how to set this buffer to not-killable?
  (midnight-delay-set 'midnight-delay "19:00pm")
  (add-hook 'midnight-hook (lambda ()
                             (with-current-buffer buffer-name
                               (call-interactively 'message-send)))))

;; some similar psuedocode
(defun schedule-send-mail-in-current-buffer ()
  (interactive ???)
  ;; days hour minute after now
  (prompt-and-get buffer-name)
  (prompt-and-get minute)
  (prompt-and-get hour)
  (prompt-and-get days)

  (rename-this-buffer buffer-name)
  (bury-buffer (get-buffer buffer-name))
  ;; calc schedule-time
  (let ((scheduled-time (build-date-time minute hour days)))
    ;; if setq timer is outside defun, it works. Why cannot it work in a defun?
    (setq monthcheck-timer
          (run-at-time
           (encode-time (get-second scheduled-time)
                        (get-minute scheduled-time)
                        (get-hour scheduled-time)
                        (get-day scheduled-time)
                        (get-month scheduled-time)
                        (get-year scheduled-time))
           nil
           (lambda ()
             (with-current-buffer buffer-name
               (call-interactively 'message-send)))))))
  • This looks interesting "mu4e-send-delay": github.com/bandresen/mu4e-send-delay – lawlist Jun 28 '17 at 6:00
  • @lawlist Does this force to use one delay time for every composed email? – cmal Jun 28 '17 at 7:29
  • I have no idea, sorry -- it was just the first hit that looked interesting on Google relating to scheduling the sending of email within Emacs. I don't use mu4e because the server mu runs 24/7 (which seems excessive), but many people love it. I didn't see any other hits on Google that looked interesting, so I suspect your options within Emacs are limited unless you want to write up a custom solution. – lawlist Jun 28 '17 at 7:51
  • Possible duplicate of send mail later in Gnus – lawlist Jun 28 '17 at 14:07
  • @lawlist: That other question is to delay the actual sending but where the message has been written ahead of time, but in his case it looks like he wants to edit the message during the delay. – Stefan Jun 29 '17 at 15:56
1

There is an accepted answer to a similar question.

Extracted information: yes, you can if you use Gnus.
See above mentioned answer for instructions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.