Email Selected Note in Evernote [Applescript]

Posted by on Mar 31, 2012 in Evernote Applescripts | No Comments

Function

Email the selected note in Evernote using Safari and Mail.

The script first export the selected note in Evernote as an HTML file to the Desktop. Then open the file using Safari and use Safari’s “Mail Contents of This Page” function to mail the the note. The reason to first open the note in Safari is to preserve all the HTML elements the note may have, including any checkbox.

Requirements

  • Evernote.app
  • Safari.app
  • Mail.app

Instruction

  • Select a note in Evernote
  • Run the script (a temporary folder named “ev_export” will be created on Desktop to hold the exported HTML file)
  • Wait for Mail.app to create a new email message (the title of the note will be inserted into the “subject” field of the new email message)
  • Specify the recipient’s email address and click send

Code

--Written by Charles Yu of Efficient Computing [https://efficientcomputing.commons.gc.cuny.edu]
--Distributed under the Creative Common Attribution-NonCommercial-ShareAlike license [CC BY-NC-SA]

--Get the POSIX path of Desktop
set desktopPath to the POSIX path of (path to desktop)

--Tell Evernote to export the selected note as HTML file in a folder named 'ev_output' in 'Desktop'
tell application "Evernote"
	set theNote to selection
	set noteTitle to the title of item 1 of theNote
	set exportFolder to ((desktopPath) & "ev_output/")
	set exportHTML to (exportFolder & noteTitle & ".html")
	export theNote to exportFolder format HTML without tags
end tell

--Open the output HTML in Safari and use Safari's 'mail content' function to create a new email message in Mail.app
tell application "Safari"
	tell front window
		open exportHTML
		delay 0.5
		email contents of current tab
		delay 0.5
		tell current tab to close
	end tell
end tell

--Remove the output files
do shell script ("rm -R " & exportFolder)

Leave a Reply

Skip to toolbar