Make mailto links open Yahoo mail on Windows

This isn’t perfect, but it’s better than nothing. I’m using Windows 7, but this should work (with a few tweaks) on other versions too. You do NOT need to install any additional software, so Yahoo Toolbar or Yahoo Messenger are NOT required to make this work. It will work with any web browser, so Internet Explorer is fine, as is anything else, the browser that’s used is whatever your default browser is.

In HTML there is a URL type that causes a mail client to be opened when links are clicked, these URLs start with mailto: and are followed by an email address (similar to how http: causes a web browser to be opened).

If you have some email software installed on your PC then this works fine, but if you use webmail, in my case Yahoo mail, you get a message telling you that you have no email software installed (or maybe something that’s installed but you don’t use gets launched, which is annoying).

With this solution, a new browser window opens and gives you a compose window, with the email addressed to where the mailto link was pointing. This is accomplished via a small VBScript.

There are two parts to this process, a registry edit to alter the mailto URL handler for the current user, and a small bit of code to process the data and launch the default web browser. The script is made somewhat larger by the “installation” routine(s) that allow you to “install” and “uninstall” the URL handler by double-clicking the VBScript file.

Copy the following and paste it into a file called YahooMailto.vbs

Option Explicit
'RCMTech Mail Handler for Yahoo Mail

Const cReg = "HKCU\Software\Classes\mailto\shell\open\command\"
Dim oArgs, oShell
Dim sText, iRet, bDoBackup

Set oArgs = WScript.Arguments
Set oShell = CreateObject("WScript.Shell")

If oArgs.Count>0 Then
      sText = oArgs(0)
      sText = replace(sText,"mailto:","")
      sText = replace(sText,"?subject=","&subject=")
      sText = replace(sText,"?body=","&body=")
      sText = replace(sText," ","%20")
      oShell.Run sText,0,False
      sText = "Use RCMTech Yahoo Mail mailto handler?" & vbCrLf & "Click Yes to install, No to remove." 
      iRet = MsgBox(sText, vbYesNoCancel, "RCMTech Yahoo Mail Handler")
      Select Case iRet
             Case 2
             Case 6
                   On Error Resume Next
                   sText = oShell.RegRead(cReg)
                   If Err.Number = 0 Then
                         bDoBackup = True
                   End If
                   On Error GoTo 0
                   If InStr(sText, WScript.ScriptFullName) Then
                         MsgBox "Mail handler seems to be installed for this user already", vbOKOnly, "RCMTech Yahoo Mail Handler"
                         If bDoBackup Then
                                oShell.RegWrite cReg & "orig", sText, "REG_SZ"
                         End If
                         oShell.RegWrite cReg, "wscript.exe " & WScript.ScriptFullName & " ""%1"""
                         MsgBox "Added mail handler value to registry", vbOKOnly, "RCMTech Yahoo Mail Handler"
                   End If
             Case 7
                   On Error Resume Next
                   sText = oShell.RegRead(cReg & "orig")
                   If Err.Number = 0 Then
                         On Error GoTo 0
                         oShell.RegWrite cReg, sText, "REG_SZ"
                         oShell.RegDelete cReg & "orig"
                         MsgBox "Reverted to previous mail handler value", vbOKOnly, "RCMTech Yahoo Mail Handler"
                         On Error GoTo 0
                         oShell.RegDelete cReg
                         MsgBox "Removed mail handler value", vbOKOnly, "RCMTech Yahoo Mail Handler"
                   End If
      End Select
End If

Put the .vbs file somewhere on your PC, I suggest something like C:\Users\Public, then double-click it and follow the instructions to change your URL handler for mailto. Double-click again to remove/revert to your previous mailto handler.

You need to be signed in to Yahoo for this to work, or to have ticked the “Keep me signed in” box when you last signed in.

Hope you find this useful.

This entry was posted in Scripting, Windows and tagged , , , , , , , , , , , . Bookmark the permalink.

10 Responses to Make mailto links open Yahoo mail on Windows

  1. rcmtech says:

    Updated script to handle mailto URLs with subject and/or body lines, and spaces.


  2. Mike R says:

    This is extremely useful! THANK YOU! Are you aware of a way to utilize “Send to” functionality to upload attachment(s) to Yahoo email?


  3. jpacklin says:

    Didn’t work for me. I click a MAILTO link and nothing happens still. I did go and change MAILTO to use Chrome in my default file type settings previously, which didn’t work. Thinking that might be interfering with this I tried to unclick and it won’t let me turn off MAILTO using Chrome. It’s grayed out.
    I did verify the line was put it into the registry in the proper place at HKCU\Software\Classes\mailto\shell\open\command\ and closed and reopened chrome.
    Any suggestions?


    • rcmtech says:

      1) Open a command prompt and type the following:
      Does that work? (i.e. is your http: handler broken)
      2) Is the script being called when you click a mailto: link? Add a line to the script:
      msgbox “Hello”
      immediately after the comment, as a new line 3. Now click a mailto: link, do you get the “Hello” message box?
      Unfortunately that’s about all the help I can give, but it might give you a few pointers. Good Luck!


      • jpacklin says:

        Thanks for responding. When I do it from the command prompt it works. I added a new line 3 as instructed above, when I click a mailto link nothing happens – the script is not being called. Like I mentioned I did verify in the registry that the entry to call the script is present. I don’t know what else to do .. like I said I’m wondering if it’s because I used the set file types option to set MAILTO to Chrome (from outlook) and you can’t unset it; it makes you pick something. Maybe I’ll change it back to Outlook and see what happens.


  4. jpacklin says:

    I changed it back to Outlook, now mailto links just open outlook – the script is not being called. I need to figure out where else in the registry mailto links are asssociated and do some experimenting.


  5. jpacklin says:

    Actually after adding that line, the vbs script won’t run – says script:Yahoomailto.vbs, line 3, char 8, error invalid character


  6. jpacklin says:

    I tweaked it and put () around the “Hello” now it does say hello when I double click the script. However it’s still not being called on mailto links :/


    • rcmtech says:

      Ahh, yeah I just noticed that WordPress has converted the double quotes to be “proper” opening and closing speech marks. In VBScript they should be just standard speech marks/double quotes (ASCII code 34). Unfortunately I have no idea what fiddly stuff might be going on in your registry, but do post back if you work it out.


      • jpacklin says:

        So far I’m coming up with very little that looks significant in the registry when I search mailto. I went to the handlers area that your script modifies and looked up a dozen lines to ftp. This looks identical to what your script adds, but a difference I noticed is that in the “shell” section is a key called (Default) REG_SZ which has a data value of “open” whereas your script installs as (value not set). So just playing around I changed the (value not set) of the mailto\shell\Default handle to be “open” instead of value not set. No change in behavior.The only significant thing that jumps out to me is when I navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\MAILTO\OpenWithList I have:
        (Default) REG_SZ (value not set)
        a REG_SZ chrome.exe
        MRUList REG_sz a

        I wonder if I could tweak this registry entry to match the one your script puts in hkcu\etc? What do you think? (Ive backed up my registry and made a restore point).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.