Mail link to current Safari page in Mac OS 10.8 with a keyboard shortcut

In Mac OS 10.8 Mountain Lion, Apple removed the Email link to this page option in Safari, replacing it with Share > Email this page, which places the entire contents of the page into the email, images and all.

Sometimes this isn't what you want, though.  Sometimes just a link is best.

I've written a short AppleScript to perform the old "just a link" function, and will explain how to make it run from within Safari using a customisable key command.

Actually, funny story.  While messing around, I discovered an undocumented keyboard shortcut which does this.  It's ⇧⌘I. This completely obviates the need for the script I wrote, but I'll keep the instructions here, incase reading about moving data between Safari and Mail using AppleScript is something you'd find useful.

  1. First, open the AppleScript Editor, which is located in /Applications/Utilities/ by default.AppleScript Editor
  2. In its Preferences > General, tick the box which says "Show Script menu in menu bar".AppleScript Editor PreferencesYou'll notice that a little script icon has appeared in the menu bar:Script menu
  3. Now switch to Safari.  In your new Scripts menu, select Open Scripts Folder > Open Safari Scripts Folder.  This will open the ~/Library/Scripts/Applications/Safari/ folder.
  4. Download the file Email link to current page.scpt.zip, unzip it and place the resultant .scpt file in the Safari Scripts Folder.  Alternatively, paste the following into a file and call it something like "Email link to current page.scpt".
    tell application "Safari"
    	set theURL to URL of current tab of window 1
    	set theName to name of current tab of window 1
    	tell application "Mail"
    		set theMessage to make new outgoing message with properties {subject:theName, content:theURL, visible:true}
    		activate
    	end tell
    end tell

    If you like, you can change the names of the applications "Safari" and "Mail" to your browsers of choice, modifying these instructions as appropriate.

  5. If you switch back to Safari, you'll notice that in the Scripts menu there's a new item at the bottom.New Script
  6. If you're happy with using this menu, you're done at this point.  If you'd rather use a keyboard shortcut to invoke this, keep reading.
  7. If you're comfortable using Quicksilver or FastScripts, probably use one of those to set up a keyboard trigger for your new script.  We'll use the standard method of Keyboard Preferences.
  8. Open System Preferences, and select the Keyboard pane and the Keyboard Shortcuts tab.
  9. In the left-hand pane, select Application Shortcuts.  Click the "+" button to add a new one.Add new keyboard shortcut
  10. In the sheet that pops up, select "Safari" from the Application drop-down, type "Email link to current page" into the Menu Title box, and type your preferred keyboard shortcut into the Keyboard Shortcut box.  I picked the shortcut ⇧⌘I, since it't not taken, and it's close to the ⌘I used by the new Share option.
    [It was, unsurprisingly, at this point that I discovered ⇧⌘I is taken, and it's taken by exactly this!]
    Anyway, it's important to note that in the Menu Title box, you have to type the name of the script exactly as it appears in the menu.

That's it!  You now have your old functionality back.

Leave a comment

Your email address will not be published. Required fields are marked *