Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Link iCal events and to-dos to to any Mail message' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Link iCal events and to-dos to to any Mail message
Authored by: smorr on Nov 15, '06 10:27:20AM
Just to echo and reply to a couple of comments:
  1. link will only be valid until message moves.
  2. MailTags 2.0 (in beta) now uses a message:// url scheme to link to the message (prior to this, MT would update ical if the message was moved)
  3. I am going to be releasing another beta (very soon) that implements events in MailTags.


[ Reply to This | # ]
Link iCal events and to-dos to to any Mail message
Authored by: FlyBoy on Nov 15, '06 12:13:22PM
Hi,

I wrote a little applescript that uses the message://messageId URL scheme. The script gets the message ID, escapes characters not allowed in a URL using a ruby script, and places the message URL on the clipboard. It can be adapted fairly easily to add the URL into an iCal event. I put it on the clipboard so that I put the URL anywhere I want it.

Here's the applescript:


set theID to ""
tell application "Mail"
tell front message viewer

set theSelMess to selected messages
if (count of theSelMess) is greater than 1 then
display dialog "Only select one message"
return
end if
tell item 1 of theSelMess
set theID to message id
end tell

end tell
set the clipboard to theID
do shell script "/Users/nacohen/bin/messID2messURL.rb"
set theclip to the clipboard
display dialog "The message URL:" & return & return & theclip & return & "is now on the clipboard."
end tell
--open location theURL

And here's the Ruby code (this could probably be done in perl, Applescript or anything you want, but I am learning Ruby and wanted to play with it some)


#!/usr/bin/env ruby
# => get clipboard contents as string
messageID = %x{pbpaste}.to_s
# => convert to message URL and encode non-alphanumeric as hexidecimal escapes
messageURL = 'message://' + messageID.gsub(/([^a-zA-Z0-9_.-]+)/n) {
'%' + $1.unpack('H2' * $1.size).join('%').upcase
}
# => open a pipe for output to pbcopy and print the new message URL
open("|/usr/bin/pbcopy","w"){|outf| outf.puts messageURL}

Hope this helps someone.

Norm

[ Reply to This | # ]

Link iCal events and to-dos to to any Mail message
Authored by: FlyBoy on Nov 15, '06 12:15:14PM

I forgot to note that the do shell script line in the applescript needs to have the path pointing to the location of the ruby script or perl script that performs the URL encoding.

Sorry for any confusion.

Norm



[ Reply to This | # ]
Link iCal events and to-dos to to any Mail message
Authored by: John M on Nov 16, '06 04:55:44AM
As FlyBoy states, you can do this without the Ruby script. I can't test this as I don't have MailTags.

Replace the following lines in the Applescript:
set the clipboard to theID 
do shell script "/Users/nacohen/bin/messID2messURL.rb" 
With:
set the clipboard to "message://" & (do shell script "python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theID)
John M

[ Reply to This | # ]