Discussion:
Capturing outgoing gnus e-mail
Ivan Kanis
2014-06-14 08:32:49 UTC
Permalink
Hi,

I would like to capture outgoing e-mail in my org file.

I use the gcc mechanism in gnus with a nnml backend.

I think I have read on the org mailing list that someone has implemented
that feature. I did a search but could not find the article.

I tried implementing it myself. I had a look at the function
gnus-inews-do-gcc. It has the group and the article number. However org
link expect the Message-ID header. How do I get it?

Thanks,

Ivan
--
Software uses US measurements, but the OS is in metric...
-- BOFH excuse #24
Bastien
2014-06-14 09:05:18 UTC
Permalink
Hi Ivan,

this is what I use :

========================================================================
;; Hack to store Org links upon sending Gnus messages

(defun bzg-message-send-and-org-gnus-store-link (&optional arg)
"Send message with `message-send-and-exit' and store org link to message copy.
If multiple groups appear in the Gcc header, the link refers to
the copy in the last group."
(interactive "P")
(save-excursion
(save-restriction
(message-narrow-to-headers)
(let ((gcc (car (last
(message-unquote-tokens
(message-tokenize-header
(mail-fetch-field "gcc" nil t) " ,")))))
(buf (current-buffer))
(message-kill-buffer-on-exit nil)
id to from subject desc link newsgroup xarchive)
(message-send-and-exit arg)
(or
;; gcc group found ...
(and gcc
(save-current-buffer
(progn (set-buffer buf)
(setq id (org-remove-angle-brackets
(mail-fetch-field "Message-ID")))
(setq to (mail-fetch-field "To"))
(setq from (mail-fetch-field "From"))
(setq subject (mail-fetch-field "Subject"))))
(org-store-link-props :type "gnus" :from from :subject subject
:message-id id :group gcc :to to)
(setq desc (org-email-link-description))
(setq link (org-gnus-article-link
gcc newsgroup id xarchive))
(setq org-stored-links
(cons (list link desc) org-stored-links)))
;; no gcc group found ...
(message "Can not create Org link: No Gcc header found."))))))

(define-key message-mode-map [(control c) (control meta c)]
'bzg-message-send-and-org-gnus-store-link)
========================================================================

Then, in a message, I use C-c C-M-c instead of C-c C-c to send the
message and create a link to it that I can reinsert later one. This
is not really capturing, but it's good enough for my needs.

HTH,
--
Bastien
Eric Abrahamsen
2014-06-14 10:06:44 UTC
Permalink
Post by Ivan Kanis
Hi,
I would like to capture outgoing e-mail in my org file.
I use the gcc mechanism in gnus with a nnml backend.
I think I have read on the org mailing list that someone has implemented
that feature. I did a search but could not find the article.
I tried implementing it myself. I had a look at the function
gnus-inews-do-gcc. It has the group and the article number. However org
link expect the Message-ID header. How do I get it?
Thanks,
Ivan
Hi Ivan,

That's something that Gnorb[1] can do. Make a capture template that
you want to use for outgoing mail TODOs, and identify it:

(setq gnorb-gnus-new-todo-capture-key "O")

Then, while you're composing the email, call
`gnorb-gnus-outgoing-do-todo' in the message buffer, which I have bound
to "C-c t".

You can also call it *after* sending the message, if you forgot, and it
will initiate the same process from the last sent message.

It works best when you're using Gcc, as that means Org is able to make a
real link to the sent message. Gnorb will try to fake it, if you're not.

If you set (setq gnorb-gnus-hint-relevant-article t), Gnorb will even
notify you when you get a reply to your sent message.

It's early days for Gnorb, but this part of it works well for me. I'd
love a little more road-testing, if you're interested!

I'm going to stick it in ELPA in a month or so, but for now:

[1]: https://github.com/girzel/gnorb

Hope it helps!
E
Ted Zlatanov
2014-09-24 21:04:35 UTC
Permalink
On Sat, 14 Jun 2014 10:32:49 +0200 Ivan Kanis <***@kanis.fr> wrote:

IK> I would like to capture outgoing e-mail in my org file.

IK> I use the gcc mechanism in gnus with a nnml backend.

IK> I think I have read on the org mailing list that someone has implemented
IK> that feature. I did a search but could not find the article.

IK> I tried implementing it myself. I had a look at the function
IK> gnus-inews-do-gcc. It has the group and the article number. However org
IK> link expect the Message-ID header. How do I get it?

Well, I use the following to maintain a diary file. It's probably
equally easy to use a Org file:

(defun message-to-diary ()
(make-diary-entry (concat
(format-time-string "%B %d, %Y %H:%M" (gnus-date-get-time (message-fetch-field "date")))
(if (message-fetch-field "newsgroups")
(concat " Sent news To: " (message-fetch-field "newsgroups"))
(concat " Sent mail To: " (message-fetch-field "to")))
" Subject: \"" (message-fetch-field "subject") "\""
" Message-ID: " (message-fetch-field "message-id")))
(save-buffer "diary"))

(add-hook 'message-sent-hook 'message-to-diary)

HTH
Ted
Steinar Bang
2014-09-25 07:45:31 UTC
Permalink
Post by Ted Zlatanov
(defun message-to-diary ()
(make-diary-entry (concat
(format-time-string "%B %d, %Y %H:%M" (gnus-date-get-time (message-fetch-field "date")))
(if (message-fetch-field "newsgroups")
(concat " Sent news To: " (message-fetch-field "newsgroups"))
(concat " Sent mail To: " (message-fetch-field "to")))
" Subject: \"" (message-fetch-field "subject") "\""
" Message-ID: " (message-fetch-field "message-id")))
(save-buffer "diary"))
Um... what does this do? Write a log of sent messages to the diary?

I thought the diary was for future appointments, and appointment
notifications?
Ted Zlatanov
2014-09-25 12:30:20 UTC
Permalink
On Thu, 25 Sep 2014 09:45:31 +0200 Steinar Bang <***@dod.no> wrote:

SB> Um... what does this do? Write a log of sent messages to the diary?

Yes.

SB> I thought the diary was for future appointments, and appointment
SB> notifications?

I choose to use the diary for sent mail and think that's appropriate,
but really I posted that code to help the OP with capturing sent e-mails
to an Org mode file.

Ted
Uwe Brauer
2014-12-14 22:58:36 UTC
Permalink
Hello

I just saw your code.
Post by Ted Zlatanov
Well, I use the following to maintain a diary file. It's probably
(defun message-to-diary ()
(make-diary-entry (concat
(format-time-string "%B %d, %Y %H:%M" (gnus-date-get-time (message-fetch-field "date")))
(if (message-fetch-field "newsgroups")
(concat " Sent news To: " (message-fetch-field "newsgroups"))
(concat " Sent mail To: " (message-fetch-field "to")))
" Subject: \"" (message-fetch-field "subject") "\""
" Message-ID: " (message-fetch-field "message-id")))
(save-buffer "diary"))
(add-hook 'message-sent-hook 'message-to-diary)
I cannot see the relevant group entry. So how are you supposed to jump
from the diary to the message.

Uwe Brauer

Loading...