The variable 'number-of-days' specifies how many days should be included in the mail; if there are no dates in this time span, no mail will be send at all.#!/usr/bin/emacs --script (setq number-of-days 3 european-calendar-style t calendar-week-start-day 1 diary-file "~/.calendar" diary-mail-addr "mymail@nomail.invalid") (add-hook 'list-diary-entries-hook 'sort-diary-entries t) (add-hook 'diary-display-hook 'fancy-diary-display) (require 'diary-lib) (when (list-diary-entries (calendar-current-date) number-of-days) (set-buffer fancy-diary-buffer) (setq text (buffer-substring (point-min) (point-max))) (mail) (mail-to) (insert diary-mail-addr) (mail-subject) (insert "Diary entries generated " (calendar-date-string (calendar-current-date))) (mail-text) (insert text) (mail-send-and-exit nil))
Send mail with upcoming Emacs calendar events
By randomsample - Posted on February 22nd, 2009
It seems it is not very well known that since Emacs 22 you can use the "--script" option to write Emacs scripts using a simple shebang line, which I like better than fiddling with "--batch", "--eval", "-l" and "-f" options. For example, I call the following script from cron to send a mail with upcoming events in one of my Emacs calendars: