From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: how to put into a journal info about the email sent Date: Fri, 24 Oct 2014 08:43:46 -0700 Message-ID: <87ppdhh3rh.fsf@ericabrahamsen.net> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhgxB-0004Md-OF for emacs-orgmode@gnu.org; Fri, 24 Oct 2014 11:39:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xhgx6-00089H-V4 for emacs-orgmode@gnu.org; Fri, 24 Oct 2014 11:39:01 -0400 Received: from plane.gmane.org ([80.91.229.3]:57343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xhgx6-000893-IA for emacs-orgmode@gnu.org; Fri, 24 Oct 2014 11:38:56 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Xhgx3-0003hl-4f for emacs-orgmode@gnu.org; Fri, 24 Oct 2014 17:38:53 +0200 Received: from c-76-28-195-250.hsd1.wa.comcast.net ([76.28.195.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 Oct 2014 17:38:53 +0200 Received: from eric by c-76-28-195-250.hsd1.wa.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 Oct 2014 17:38:53 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org David Belohrad writes: > Dear All, > > i'm using org. And I'm using notmuch (that's why I address both mailing > lists). Now, writing an email in everyday bussiness requires a > non-significant time of your workhours. So I'd like to have this event > in my org agenda. So any time I send some email with a given subject, > I'd like to 'automatically' entry the information about it into > e.g. sentmails.org in form of a diary entry, with appropriate tag. I do something like this in Gnorb, which I'd recommend you use except it's mostly Gnus specific. I do it in two parts, but you could do it in one. Basically I add a function to the `message-header-hook' (which ensures that all the message headers have been generated properly). The important bits look like: (save-restriction (message-narrow-to-headers) (let ((link (and (mail-fetch-field "Gcc") (org-store-link nil))) (org-capture-link-is-already-stored t) ;; Collect date, subject, to, and msg-id with ;; `mail-fetch-field'. Construct date-ts and date-ts-ia with ;; (format-time-string ;; (org-time-stamp-format t [t]) ;; (date-to-time date)) ) (if link (org-add-link-props :date date :date-timestamp date-ts :date-timestamp-inactive date-ts-ia :annotation link) (org-store-link-props :subject subject :to to :date date :date-timestamp date-ts :date-timestamp-inactive date-ts-ia :message-id msg-id :annotation link)) (org-capture nil gnorb-gnus-new-todo-capture-key))) So, if a "Gcc:" header is present, make the link using `org-store-link', then add more fields using `org-add-link-props'. If it's not, then fake it by storing all necessary fields using `org-store-link-props'. Because we let `org-capture-link-is-already-stored' to t, the capture process doesn't try to create a new link, but just uses the values we've stored. Obviously the downside is that, without a "Gcc:" header, org can't actually make a real link to the message. It doesn't know where it's going to be. However if you know that all your sent messages can be reached with a link that looks like "notmuch:id#Message-id", then you can make that yourself in your org capture template with something like "[[notmuch:id#%:message-id][%:subject]]" I hope that's not too confusing! See: https://github.com/girzel/gnorb/blob/master/gnorb-gnus.el#L259 https://github.com/girzel/gnorb/blob/master/gnorb-gnus.el#L437 Yours, Eric > In example: > > I'm sending a mail to Tom, with subject 'dealing vme register > mapping'. > > At the moment I send this email (using smtpmail), I'd like an entry in > the sentmails.org as follows: > > -------------------------------------------------------------------------------- > ** 2014-10 October > *** 2014-10-02 Thursday > **** dealing vme register mapping :mail: > [[notmuch:id:7a97bb93e66a41878edd4c04fa764963@cernfe03.cern.ch][dealing > vme register mapping]] > -------------------------------------------------------------------------------- > > I thought that I can use following > > (add-hook 'message-send-hook ') > > to hook on sending and generate a capture entry. In fact this works > pretty well _EXCEPT_ the link to the mail sent. The org-store-link > cannot apparently store a link to an email, which so far was not sent > (and not received?) because it claims that > > 'org-gnus-store-link: Can not create link: No Gcc header found' > > Hence this is pretty fatal for my diary entry. My question is: is there > any way how to link not-yet-sent/received email as an org-link? Or is > there any way to generate Gcc header before the email is sent and use > this header during sending? Or is > there any other way how to put into my agenda sent emails? > > many thanks > > david