Created
July 29, 2012 18:48
-
-
Save roderik/3201094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set newline to ASCII character 10 | |
| tell application "Mail" | |
| using terms from application "Mail" | |
| set selectedMails to selection | |
| set eachMessage to first item of selectedMails | |
| set the selected_message to item 1 of eachMessage | |
| set message_id to urlencode(the message id of eachMessage) of me | |
| set message_body to content of eachMessage | |
| set theSubject to the subject of the eachMessage & " (From " & the sender of the eachMessage & ")" | |
| set message_url to "[url=message:%3C" & (message_id) & "%3E]" & theSubject & "[/url]" | |
| set theBody to "Link to Message: " & message_url & newline & newline & message_body | |
| tell application "Things beta" | |
| set newToDo to make new to do with properties {name:theSubject, notes:theBody} | |
| end tell | |
| do shell script "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -message 'Task Created:" & theSubject & "' -title 'Mail 2 Things' -activate 'com.culturedcode.things_beta'" | |
| tell application "Growl.app" | |
| set the allNotificationsList to ¬ | |
| {"Task Created"} | |
| set the enabledNotificationsList to ¬ | |
| {"Task Created"} | |
| «event register» given «class appl»:¬ | |
| "Create Task from Multiple Mail (Growl Enabled)", «class anot»:allNotificationsList ¬ | |
| , «class dnot»:enabledNotificationsList ¬ | |
| , «class iapp»:"Things" | |
| «event notifygr» given «class name»:¬ | |
| "Task Created", «class titl»:¬ | |
| "Task created in Things", «class desc»:¬ | |
| theSubject, «class appl»:"Create Task from Multiple Mail (Growl Enabled)" | |
| end tell | |
| end using terms from | |
| end tell | |
| on urlencode(theText) | |
| set theTextEnc to "" | |
| repeat with eachChar in characters of theText | |
| set useChar to eachChar | |
| set eachCharNum to ASCII number of eachChar | |
| if eachCharNum = 32 then | |
| set useChar to "+" | |
| else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then | |
| set firstDig to round (eachCharNum / 16) rounding down | |
| set secondDig to eachCharNum mod 16 | |
| if firstDig > 9 then | |
| set aNum to firstDig + 55 | |
| set firstDig to ASCII character aNum | |
| end if | |
| if secondDig > 9 then | |
| set aNum to secondDig + 55 | |
| set secondDig to ASCII character aNum | |
| end if | |
| set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string | |
| set useChar to numHex | |
| end if | |
| set theTextEnc to theTextEnc & useChar as string | |
| end repeat | |
| return theTextEnc | |
| end urlencode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment