Given that you want to put this into WordPress, I assume that you just want to insert a tag like href = "mailto:" into your document for the current selected text.
The easiest way is to create a basic plugin. You can do this on the same page where tinyMCE is initialized. In the example below, the selected text with static mailto will be migrated.
tinymce.create('tinymce.plugins.MailToPlugin', { init : function(ed, url) { ed.addCommand('mceMailTo', function() { var linkText = ed.selection.getContent({format : 'text'}); var newText = "<a href='mailto: foo@bar.com ?subject=testing'>" + linkText + "</a>" ed.execCommand('mceInsertContent', false, newText); });
Of course, you need to create an image (mailto.gif) for the toolbar button.
Then you just add to the list of plugins
plugins: '-mailto'
and put mailto on the toolbar.
Of course, if you want the end user to specify an email address and subject, you will need a dialog. There is a good example of how to create a plugin on the TinyMCE website in Creating a Plugin
Unfortunately, I cannot comment on how you will do this in WordPress, but I suspect that you will need to customize the version of the WordPress tinyMCE plugin.
source share