Use Webmail as the Default “mailto” Handler in Windows

Note: A guide for the impatient is at the bottom.

I was trying to configure Internet Explore to use Comcast webmail as the default handler for mailto links recently. As I’m not really a Windows user, I was appalled at the dreary selection of add-ons for IE and the inconvenience of Windows’ “Default Programs” manager. From “Default Programs” you would expect to be able to pick any application you want to be the “mailto” handler, but this is not the case.

I found an article describing how to add handlers for any type of URL, and went from there to construct a hack that allows you to use any website as a mailto handler.

It appears the Windows/IE has the following pipeline for handling URLs when they are clicked:

  1. The text of the URL is analyzed to infer the protocol (http, ftp, etc)
  2. The registry is searched to see if a handler exists
  3. The handler is invoked in the way specified by the “open” key in registry

To jump right in, lets set up our own mailto handler.

Start regedit and navigate to the following key: HKEY_CLASSES_ROOT\mailto\Shell\open\command

This key should have a value “(default)” that specifies a command to run when a mailto URL is clicked. If you have outlook installed, it should look something like this:

"C:\PROGRA~2\MICROS~1\Office14\OUTLOOK.EXE" -c IPM.Note /m "%1"

This is simply specifying the location of an executable and the arguments to pass to it. In this case %1 is referring to the entire URL that was clicked. So for example, if I were to click a link with the URL “” the %1 would be replaced with the text “”.

Our hack will be to write a batch file that will take this URL, remove the first seven characters (“mailto:”), and give the email address to our favorite webmail service in our favorite browser.

Supposing that C:\Users\Kris\handle-email.bat is the location of our custom script, changing the “(default)” value to the following would run the script when a mailto URL is clicked.

C:\Users\Kris\handle-email.bat %1

This just leaves making the actual script. Create a file called handle-email.bat and place it somewhere out of the way. Open it in your favorite text editor and paste the following:

set address=%1
set address=%address:~7%
start iexplore ""

The first line assigns the arguments provided to the script to the variable called “address.” In our set up, this will be things like “”. The second line removes the first seven characters to get rid of the prefix “mailto:”. The last line starts IE so that it goes to the URL provided. In this example, it goes to Comcast’s compose message page and populates the “To:” field. Similar “magic” URLs exist for gmail and Windows Live.

Other webmail service link formats:

For the impatient:

Edit “(default)” in HKEY_CLASSES_ROOT\mailto\Shell\open\command to contain the following:

C:\path\to\your\script.bat %1

Make the script:

set address=%1
set address=%address:~7%
start iexplore ""


  1. Pingback: mailto handling |

  2. Good info.

    I noticed that using GMAIL’s new themes it didn’t work out, I need to hack it and add “ui=1″ to the URI.

    It’d be nice, and maybe someday I will, to expand on adding SUBJECT, CC, BODY also for some links that have that already in the mailto link. Quick filtering for &= in batch should be easy enough to make it happen.

  3. Pingback: mailto handling | Rich's Tech Blog

  4. Thanks for sharing! I used this to set my “mailto” to Outlook Web Access. Very useful write-up!

  5. Yes, thanks! I use Firefox and GMail, and here’s the slight modification I made:

    —– C:\bin\webmail_handler.cmd

    @set address=%1
    @set address=%address:~7%

    @set BROWSER_PATH=”C:\Program Files (x86)\Mozilla Firefox 4\firefox.exe”
    @set WEBMAIL_URL=””


    Also, I like using the “reg” command (rather than rededit), so here’s what I used to set the registry entry:

    @reg add HKCR\mailto\Shell\open\command /ve /d C:\bin\webmail_handler.cmd

  6. Actually, I’m sorry, but that script doesn’t quite work. Obviously, “to=some@%address%” should be more like “to=%address%”, but even that doesn’t work right. Feel free to delete/disapprove that message, and maybe I can figure out what’s wrong and re-post. Or, leave it, but let others know it’s wrong, and maybe someone else can fix it. Sorry. :-]

  7. The web browser is actually quite easy to resolve, just leave out the “iexplore” and Windows will open the link in your default browser.

    set address=%1
    set address=%address:~7%
    start “”

Leave a Comment