From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Christopher J. White" Subject: Re: org-capture and org-link-type for Outlook mail messages on Mac OSX Date: Sun, 03 Jun 2012 07:16:41 -0400 Message-ID: <4FCB4799.80906@grierwhite.com> References: <4FCB42D2.6010306@grierwhite.com> Reply-To: orgmode@grierwhite.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sb8nh-0006d1-RV for emacs-orgmode@gnu.org; Sun, 03 Jun 2012 07:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sb8nf-0002St-RM for emacs-orgmode@gnu.org; Sun, 03 Jun 2012 07:16:49 -0400 Received: from mail26c25.carrierzone.com ([64.29.147.36]:55853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sb8nf-0002SP-KC for emacs-orgmode@gnu.org; Sun, 03 Jun 2012 07:16:47 -0400 Received: from cwhite-mbpro.local (pool-108-7-154-211.bstnma.east.verizon.net [108.7.154.211]) (authenticated bits=0) by mail26c25.carrierzone.com (8.13.6/8.13.1) with ESMTP id q53BGgSW030877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 3 Jun 2012 11:16:44 GMT In-Reply-To: <4FCB42D2.6010306@grierwhite.com> 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 Ok -- just realized I had left in the selection of a custom org-capture-template which will likely not be in anyone else's config, so I made the org-capture-template configurable, and set to nil by default. Modified script below.. ...cj -- OutlookToEmacsOrg -- -- This script uses org-protocol to capture the currently selected message in outlook -- as an Org item. The item creates a link of type 'mac-outlook' with the message ID -- within Outlook that can later be used by mdfind to find that message. -- -- If more than one message is selected, only the first message is used. If no message -- is selected, the script does nothing. -- -- The Title passed to org-protocol is formatted as "[Sender] Subject", but could -- easily be modifed as below to any text. -- -- See http://orgmode.org/worg/org-contrib/org-protocol.html for details about -- how org-protocol works. -- -- This script assumes emacsclient is available via the Carbon Emacs application, but -- can be changed via the emacsclientBinary below. -- -- Script Installation for Outlook -- 1. Startup AppleScript Editor -- 2. Paste this script into a new file -- 3. Save as "OutlookToEmacsOrg" of file type "Script Bundle" in the directory: -- /Users//Library/Application Support/Microsoft/Office/Outlook Script Menu Items -- 4. Restart Outlook, and this should show up in the Script menu (the squiggly next to Help) -- -- You probably also assign a shortcut via System Preferences. -- -- Emacs mac-outlook link support, put the following in your .emacs: -- -- (org-add-link-type "mac-outlook" 'org-mac-outlook-open) -- -- (defun org-mac-outlook-open (msgid) -- "Open a message in outlook" -- (shell-command (format "open \"`mdfind com_microsoft_outlook_recordID==%s`\"" msgid))) -- -- Tested on Mac OS X 10.7.3, Emacs 23.4.2, Org 7.8.03, Outlook for Mac 2011 -- -- Special thanks to Lutz Meyer / LuMe96(at)gmail.com -- I got the critical -- pieces of applescript from OutlookToThings.scpt written by Lutz. property emacsclientBinary : "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" -- Set to the empty string to use the default capture template, or fill -- in the letter code from org-capture-templates property orgCaptureTemplate : "" --property orgCaptureTemplate : "x" on urlencode(plaintext) set enctext to do shell script "python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of plaintext return enctext end urlencode tell application "Microsoft Outlook" set msgCount to count current messages if (msgCount < 1) then return end if set myMessage to (the first item of (get current messages)) set myID to id of myMessage as string set mySubject to subject of myMessage set mySender to sender of myMessage set mySenderName to name of mySender set myTitle to "[" & mySenderName & "] " & mySubject set myCmd to emacsclientBinary & " \"org-protocol:/capture:" if (length of orgCaptureTemplate > 0) then set myCmd to myCmd & "/" & orgCaptureTemplate end if set myCmd to myCmd & "/mac-outlook:" & myID set myCmd to myCmd & "/" & (my urlencode(myTitle)) set myCmd to myCmd & "\"" --display dialog myCmd tell application "Emacs" activate end tell do shell script myCmd set the clipboard to myCmd end tell