emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* mail agenda similar to `diary-mail-entries'
@ 2007-05-15 12:50 Patrick Drechsler
  2007-05-15 18:47 ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Drechsler @ 2007-05-15 12:50 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

is it possible to mail the agenda using a cron job similar to the
diary function `diary-mail-entries'?

Currently I have this shell script for mailing the diary entries to
myself:

--8<---------------cut here---------------start------------->8---
#!/bin/bash
## send diary entries by mail
emacs \
    --batch \
    --load ~/.emacs \
    --load ~/.gnus \
    --funcall diary-mail-entries \
    --eval "(setq diary-mail-days 7)"
--8<---------------cut here---------------end--------------->8---

It would be nice to also include the agenda in this setup.

Any ideas?

Cheers,

Patrick 
-- 
"You know the world is going crazy when the best rapper is a white
guy, the best golfer is a black guy, the Swiss hold the America's Cup,
France is accusing the US of arrogance, and Germany doesn't want to go
to war."          -- Charles Barkley

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mail agenda similar to `diary-mail-entries'
  2007-05-15 12:50 mail agenda similar to `diary-mail-entries' Patrick Drechsler
@ 2007-05-15 18:47 ` Carsten Dominik
  2007-06-09 23:36   ` Patrick Drechsler
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2007-05-15 18:47 UTC (permalink / raw)
  To: Patrick Drechsler; +Cc: emacs-orgmode

Untested:

emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a")' \
        | mail user@address.com


With (setq org-agenda-include-diary t), the diary will
be part of the mailing automatically.

- Carsten

On May 15, 2007, at 14:50, Patrick Drechsler wrote:

> Hi,
>
> is it possible to mail the agenda using a cron job similar to the
> diary function `diary-mail-entries'?
>
> Currently I have this shell script for mailing the diary entries to
> myself:
>
> --8<---------------cut here---------------start------------->8---
> #!/bin/bash
> ## send diary entries by mail
> emacs \
>     --batch \
>     --load ~/.emacs \
>     --load ~/.gnus \
>     --funcall diary-mail-entries \
>     --eval "(setq diary-mail-days 7)"
> --8<---------------cut here---------------end--------------->8---
>
> It would be nice to also include the agenda in this setup.
>
> Any ideas?
>
> Cheers,
>
> Patrick
> -- 
> "You know the world is going crazy when the best rapper is a white
> guy, the best golfer is a black guy, the Swiss hold the America's Cup,
> France is accusing the US of arrogance, and Germany doesn't want to go
> to war."          -- Charles Barkley
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mail agenda similar to `diary-mail-entries'
  2007-05-15 18:47 ` Carsten Dominik
@ 2007-06-09 23:36   ` Patrick Drechsler
  2007-06-10  4:37     ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Drechsler @ 2007-06-09 23:36 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik <dominik@science.uva.nl> writes:

> Untested:
>
> emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a")' \
>        | mail user@address.com
>
>
> With (setq org-agenda-include-diary t), the diary will
> be part of the mailing automatically.

I am very sorry for the late reply.

Thank you Carsten for your script!

The problem I am having with your approach is that `mail' requires a
full blown MTA. And since the diary script works fine with Emacs/Gnus
I was wondering if an approach along those lines might work, but to no
avail so far:

Here is the script I a trying to use:

--8<---------------cut here---------------start------------->8---
emacs \
    --batch \
    --load ~/.emacs.d/init.el \
    --load ~/.emacs.d/.gnus \
    --funcall org-mail
--8<---------------cut here---------------end--------------->8---


And I have tried this in my ~/.emacs (well, actually
~/.emacs.d/init.el, but that should not make a difference):

--8<---------------cut here---------------start------------->8---
;;; Test 1: this sends a message, but only replicates the header in the
;;; body. The actual body (the agenda) is not present.
;; (defun org-mail ()
;;   "Send mail of agenda to myself."
;;   (org-batch-agenda "a") 
;;   (compose-mail diary-mail-addr "agenda")
;;   (insert (buffer-string))
;;   (call-interactively (get mail-user-agent 'sendfunc)))

;;; Test 2
;;; ERROR:
;;; Buffer is read-only: #<buffer *Org Agenda*>
;; (defun org-mail ()
;;   "Send mail of agenda to myself."
;;   (compose-mail diary-mail-addr "agenda")
;;   (insert (org-batch-agenda "a"))
;;   (call-interactively (get mail-user-agent 'sendfunc)))

;;; Test 3:
;;; ERROR:
;;; Invalid header line (maybe a continuation line lacks initial whitespace)
;; (defun org-mail ()
;;   "Send mail of agenda to myself."
;;   (compose-mail diary-mail-addr "agenda")
;;   (insert (org-agenda-list "a"))
;;   (call-interactively (get mail-user-agent 'sendfunc)))
--8<---------------cut here---------------end--------------->8---

Maybe it is obvious to you or somebody else what I am doing wrong. I
have the impression that this might work somehow.

Thankful for any further input/ideas,

Patrick
-- 
OS's and GUI's come and go, only Emacs has lasting power.
(Per Abrahamsen)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: mail agenda similar to `diary-mail-entries'
  2007-06-09 23:36   ` Patrick Drechsler
@ 2007-06-10  4:37     ` Carsten Dominik
  2007-06-10  5:13       ` Eddward DeVilla
  2007-06-11 11:10       ` Patrick Drechsler
  0 siblings, 2 replies; 6+ messages in thread
From: Carsten Dominik @ 2007-06-10  4:37 UTC (permalink / raw)
  To: Patrick Drechsler; +Cc: emacs-orgmode


On Jun 10, 2007, at 1:36, Patrick Drechsler wrote:

> Carsten Dominik <dominik@science.uva.nl> writes:
>
>> Untested:
>>
>> emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a")' \
>>        | mail user@address.com
>>
>>
>> With (setq org-agenda-include-diary t), the diary will
>> be part of the mailing automatically.
>
> I am very sorry for the late reply.
>
> Thank you Carsten for your script!
>
> The problem I am having with your approach is that `mail' requires a
> full blown MTA.

what is an MTA?

> And since the diary script works fine with Emacs/Gnus
> I was wondering if an approach along those lines might work, but to no
> avail so far:
>
> Here is the script I a trying to use:
>
> --8<---------------cut here---------------start------------->8---
> emacs \
>     --batch \
>     --load ~/.emacs.d/init.el \
>     --load ~/.emacs.d/.gnus \
>     --funcall org-mail
> --8<---------------cut here---------------end--------------->8---
>
>
> And I have tried this in my ~/.emacs (well, actually
> ~/.emacs.d/init.el, but that should not make a difference):
>
> --8<---------------cut here---------------start------------->8---
> ;;; Test 1: this sends a message, but only replicates the header in the
> ;;; body. The actual body (the agenda) is not present.
> ;; (defun org-mail ()
> ;;   "Send mail of agenda to myself."
> ;;   (org-batch-agenda "a")
> ;;   (compose-mail diary-mail-addr "agenda")
> ;;   (insert (buffer-string))
> ;;   (call-interactively (get mail-user-agent 'sendfunc)))


When you do `(insert (buffer-string))', then you are already in the
mail buffer, so indeed you are only duplocating the content of the
mail buffer.  You need to do something like this:

(defun org-mail ()
   "Send mail of agenda to myself."
   (org-batch-agenda "a")
   (let ((str (buffer-string)))
      (compose-mail diary-mail-addr "agenda")
      (insert str)
      (call-interactively (get mail-user-agent 'sendfunc))))


In the following two approach you are assuming that
(org-batch-agenda "a") would *return* the agenda.  It does
not.  Instead yu are trying to indert the return value
of this function (don't even know what it would be...)
into the agenda buffer, which is indeed read-only

>
> ;;; Test 2
> ;;; ERROR:
> ;;; Buffer is read-only: #<buffer *Org Agenda*>
> ;; (defun org-mail ()
> ;;   "Send mail of agenda to myself."
> ;;   (compose-mail diary-mail-addr "agenda")
> ;;   (insert (org-batch-agenda "a"))
> ;;   (call-interactively (get mail-user-agent 'sendfunc)))
>

Below the same problem as before...

> ;;; Test 3:
> ;;; ERROR:
> ;;; Invalid header line (maybe a continuation line lacks initial 
> whitespace)
> ;; (defun org-mail ()
> ;;   "Send mail of agenda to myself."
> ;;   (compose-mail diary-mail-addr "agenda")
> ;;   (insert (org-agenda-list "a"))
> ;;   (call-interactively (get mail-user-agent 'sendfunc)))
> --8<---------------cut here---------------end--------------->8---

Hope this helps.

- Carsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: mail agenda similar to `diary-mail-entries'
  2007-06-10  4:37     ` Carsten Dominik
@ 2007-06-10  5:13       ` Eddward DeVilla
  2007-06-11 11:10       ` Patrick Drechsler
  1 sibling, 0 replies; 6+ messages in thread
From: Eddward DeVilla @ 2007-06-10  5:13 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Patrick Drechsler, emacs-orgmode

On 6/9/07, Carsten Dominik <dominik@science.uva.nl> wrote:
>
> On Jun 10, 2007, at 1:36, Patrick Drechsler wrote:
>
> > Carsten Dominik <dominik@science.uva.nl> writes:
> > The problem I am having with your approach is that `mail' requires a
> > full blown MTA.
>
> what is an MTA?

Mail Transport Agent.  It's a mail server.  Something like sendmail or qmail.

Edd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mail agenda similar to `diary-mail-entries'
  2007-06-10  4:37     ` Carsten Dominik
  2007-06-10  5:13       ` Eddward DeVilla
@ 2007-06-11 11:10       ` Patrick Drechsler
  1 sibling, 0 replies; 6+ messages in thread
From: Patrick Drechsler @ 2007-06-11 11:10 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik <dominik@science.uva.nl> writes:

> On Jun 10, 2007, at 1:36, Patrick Drechsler wrote:
>
>> Carsten Dominik <dominik@science.uva.nl> writes:

[...]

>> Here is the script I a trying to use:
>>
>> --8<---------------cut here---------------start------------->8---
>> emacs \
>>     --batch \
>>     --load ~/.emacs.d/init.el \
>>     --load ~/.emacs.d/.gnus \
>>     --funcall org-mail
>> --8<---------------cut here---------------end--------------->8---
>>
>>
>> And I have tried this in my ~/.emacs (well, actually
>> ~/.emacs.d/init.el, but that should not make a difference):
>>
>> --8<---------------cut here---------------start------------->8---
>> ;;; Test 1: this sends a message, but only replicates the header in the
>> ;;; body. The actual body (the agenda) is not present.
>> ;; (defun org-mail ()
>> ;;   "Send mail of agenda to myself."
>> ;;   (org-batch-agenda "a")
>> ;;   (compose-mail diary-mail-addr "agenda")
>> ;;   (insert (buffer-string))
>> ;;   (call-interactively (get mail-user-agent 'sendfunc)))
>
>
> When you do `(insert (buffer-string))', then you are already in the
> mail buffer, so indeed you are only duplocating the content of the
> mail buffer.  You need to do something like this:
>
> (defun org-mail ()
>   "Send mail of agenda to myself."
>   (org-batch-agenda "a")
>   (let ((str (buffer-string)))
>      (compose-mail diary-mail-addr "agenda")
>      (insert str)
>      (call-interactively (get mail-user-agent 'sendfunc))))

Thank you very much Carsten! Works like a charm! I also appreciate you
taking the time to explain why my Lisp snipplets didn't work.

Cheers,

Patrick
-- 
"Statistics are like bikinis. What they reveal is suggestive, but what
they conceal is vital" --Aaron Levenstein

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-06-11 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-15 12:50 mail agenda similar to `diary-mail-entries' Patrick Drechsler
2007-05-15 18:47 ` Carsten Dominik
2007-06-09 23:36   ` Patrick Drechsler
2007-06-10  4:37     ` Carsten Dominik
2007-06-10  5:13       ` Eddward DeVilla
2007-06-11 11:10       ` Patrick Drechsler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).