From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk-Jan C. Binnema Subject: ms-exchange invitation --> org-mode appointment Date: Sun, 18 Jul 2010 13:45:15 +0300 Message-ID: <20100718104515.4C21039C72A@djcbsoftware.nl> Reply-To: djcb@djcbsoftware.nl Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sun_Jul_18_13:45:15_2010-1" Return-path: Received: from [140.186.70.92] (port=58261 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OaRN4-0000jA-SH for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 06:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OaRN2-0002Ix-Qv for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 06:45:22 -0400 Received: from vs10.mail.saunalahti.fi ([195.197.172.105]:42533) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OaRN2-0002IT-HI for emacs-orgmode@gnu.org; Sun, 18 Jul 2010 06:45:20 -0400 Received: from saunalahti-vams (localhost [127.0.0.1]) by vs10.mail.saunalahti.fi (Postfix) with SMTP id 6944E1A403B for ; Sun, 18 Jul 2010 13:45:17 +0300 (EEST) Received: from gw01.mail.saunalahti.fi (gw01.mail.saunalahti.fi [195.197.172.115]) by vs10.mail.saunalahti.fi (Postfix) with ESMTP id 57E2C1A403B for ; Sun, 18 Jul 2010 13:45:17 +0300 (EEST) Received: from djcbsoftware.nl (a88-114-89-181.elisa-laajakaista.fi [88.114.89.181]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by gw01.mail.saunalahti.fi (Postfix) with ESMTP id 65D3E15124B for ; Sun, 18 Jul 2010 13:45:16 +0300 (EEST) Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1]) by djcbsoftware.nl (Postfix) with ESMTP id 4C21039C72A for ; Sun, 18 Jul 2010 13:45:15 +0300 (EEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Multipart_Sun_Jul_18_13:45:15_2010-1 Content-Type: text/plain; charset=US-ASCII Hi all, At work we have the typical MS-Exchange setup for mail and agenda. Only Outlook as a client is a first-class citizen in this setup, but since there are many non-Outlook users, mail can also be accessed using IMAP, and appointments are turned into emails with hyperlinks to access them in Outlook-WebAccess in a web browser. Personally, I like to use org-mode for my planning, and I needed to manually make org-TODO's for the corresponding Outlook events. However, attached find an attempt at automating this. The idea is that it extracts the information from the Exchange-emails I get and turn that into an org-TODO, using org-capture. It's quite trivial, but I've found it useful for me - hopefully it's useful for others as well. Note, the code makes the assumption there's a line like: "When: 09 July, 2010 10:00-11:00 (GMT+02:00) Helsinki, ..." I'm not sure what varieties exist in the wild, I'd be happy to update the regexps. (Maybe there are translations of 'When'? Or am/pm clocks?) Anyway, it works like this: you select (mark) the parts of the email you want to add to your org-todo item, and then invoke: M-x org-exchange-capture-invitation after that, 'org-capture' should handle the rest, provided you have something like ("E" "ExchangeInvite" entry (file+headline "todo.org" "Invites") "* TODO %c\n") in your org-capture-templates (something that has 'E' as the key, and takes a "%c") Note, this is in the early at-least-it-works-for-me stages, the elisp is a bit ugly, it requires org-capture etc.; suggestions/improvements are very welcome; see the notes in the source file. Best wishes, Dirk. --Multipart_Sun_Jul_18_13:45:15_2010-1 Content-Type: text/plain; type=emacs-lisp; charset=US-ASCII Content-Disposition: attachment; filename="org-exchange-capture.el" Content-Transfer-Encoding: 7bit ;; org-exchange-capture.el, v0.0.1 ;; written by: Dirk-Jan C. Binnema ;; License: GPLv3+ (require 'org-capture) ;; turn the e-mails sent MS-Exchange about invitation/appointments into org-TODOs ;; using 'org-capture'. ;; The idea is that you select (mark) the parts of the email you want to add to ;; your org-todo item, and then invoke M-x djcb-capture-exchange-invite; ;; Some caveats: ;; - obviously, this is just a one-way copy, it won't make you 'accept' an ;; invitation, nor does it get any updates ;; - it seems to work with the emails I get from Exchange (I've encountered two ;; different kinds). But there may be more; at least the ones I get are in ;; English, there are probably other versions as well. I'd be interested in ;; extending the regexps with more cases. ;; - it requires org-capture, which is fairly new; it should be easy to support ;; org-remember as well though. Also, I only tested with Wanderlust as e-mail ;; client; it *should* work with others as well though... ;; Note that that the message buffer must be the active buffer; ;; ie. it won't work in the 'Summary' (Wanderlust) (defun djcb-exchange-invite-time-to-org-date() "try to to find the Time/Date from an Exchange-invitation e-mail in the current buffer, and convert it into an org-mode date, or `nil' if it's not found." "get the time/date of an Outlook invite in org-mode notation" (let ((date) (time-begin) (time-end)) (save-excursion (save-match-data (beginning-of-buffer) (if (re-search-forward (concat "^When: \\([0-9]+ [a-z]+,? [0-9]\\{4\\}\\) " "\\([0-9]+:[0-9]+\\)-\\([0-9]+:[0-9]+\\)") nil t 1) (progn (setq date (parse-time-string (match-string-no-properties 1)) time-begin (match-string-no-properties 2) time-end (match-string-no-properties 3)) (format "<%d-%02d-%02d %s--%s>" (elt date 5) (elt date 4) (elt date 3) time-begin time-end)) (message "No match") nil))))) (defun djcb-exchange-invite-subject() "get the subject of an MS-Exchange invite e-mail in the current buffer" (save-excursion (save-match-data (beginning-of-buffer) (when (re-search-forward "^Subject: \\(.*\\)" nil t 1) (match-string-no-properties 1))))) (defun org-exchange-capture-invitation () "capture the MS-Exchange invite e-mail in buffer into an org-mode agenda item using the org-capture system. For this to work, you'll need to add to your `org-capture-templates' an item with a shortcut key of 'E', e.g. (\"E\" \"ExchangeInvite\" entry (file+headline \"todo.org\" \"Meetings\") \"* TODO %c\\n\") any text you select (mark) in the buffer will be added to to captured TODO; thus you can add the relevant details to the org TODO item. " (interactive) (let( (time (djcb-exchange-invite-time-to-org-date)) (title (djcb-exchange-invite-subject)) (txt (if (use-region-p) (buffer-substring-no-properties (region-beginning) (region-end)) ""))) (when time (kill-new (concat title " " time "\n\t" txt)) ;; hack: prepend to kill ring (org-capture nil "E")))) (provide 'org-exchange-capture) --Multipart_Sun_Jul_18_13:45:15_2010-1 Content-Type: text/plain; charset=US-ASCII -- Dirk-Jan C. Binnema Helsinki, Finland e:djcb@djcbsoftware.nl w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C --Multipart_Sun_Jul_18_13:45:15_2010-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Multipart_Sun_Jul_18_13:45:15_2010-1--