#!/usr/bin/emacs --script (setq number-of-days 3 org-agenda-show-all-dates nil org-agenda-files `(,(expand-file-name "~/org")) org-agenda-include-diary t european-calendar-style t calendar-week-start-day 1 diary-show-holidays-flag nil diary-file "~/.calendar" mail-addr "address@nomail.invalid") (org-agenda-list nil nil number-of-days) (with-current-buffer org-agenda-buffer-name (unless (eobp) (setq text (buffer-substring-no-properties (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)))
Adapt the variables to your liking, make the script executable and use it e.g. with cron. Since org-agenda-show-all-dates is set to nil, no mail will be sent if there are no items in your agenda. I also include my diary file, since I still keep some stuff there, but you may want to disable that.
/usr/bin/yes p | /usr/local/bin/emacs -batch -l ~/.emacs -eval '(org-batch-agenda "#")' 2>/dev/null | /usr/bin/mailx -s'Stuck projects' me@example.comNever even thought about trying to send email from Emacs itself...this idea of Emacs as scriptable is still foreign to me. :-)The thing I like about Emacs scripting is that you can easily extend it later. When I used "-eval", I often found myself producing longer and longer commands because I added some feature, until I finally decided to put the code into a file. For example, in this case it was important for me to not get any mail when there are no items in the agenda.