A Mail.app plugin for Sublime Text 3
I wrote my first plugin for Sublime Text. It is quite simple. It takes the text of the current document and turns it into a new Mail.app message. The first line of text is used as the subject line.
Originally I wanted it to use converted markdown text, but Mail’s AppleScript interface has no proper API for HTML messages.1
To implement AppleScript in my plugin I used Dr. Drang’s Code for combining Python and AppleScript:
But that code doesn’t work with Sublime Text 3. Sublime Text 3 uses Python version 3.3. Since Python 3, quite a lot has changed, especially in the treatment of Unicode text.
After some searching I found the small change I needed to make the code work:
needs to be changed to
That is because Python 3 internally transforms any text into binary
data. If you want to output Unicode again, you first have to reencode it with
Maybe this will be helpful to somebody else.
Well, there is an undocumented API for that but it doesn’t seem to work properly. ↩