Finding Default MAPI Client

by May 1, 2014

Your MAPI client is the email client that by default is used with URLs like "mailto:". To find out if there is a MAPI client, and if so, which one it is, here is a function that retrieves this information from the Windows Registry.

function Get-MAPIClient
{
    function Remove-Argument
    {
      param
      (
        $CommandLine
      )
  
      $divider = ' '
      if ($CommandLine.StartsWith('"')) 
      { 
        $divider = '"'
        $CommandLine = $CommandLine.SubString(1)
      }
  
      $CommandLine.Split($divider)[0]
    } 
  
  $path = 'Registry::HKEY_CLASSES_ROOT\mailto\shell\open\command'
  
  # create new object to return values 
  $returnValue = 1 | Select-Object -Property HasMapiClient, Path, MailTo
  
  $returnValue.hasMAPIClient = Test-Path -Path $path
  
  if ($returnValue.hasMAPIClient)
  {
    $values = Get-ItemProperty -Path $path
    $returnValue.MailTo = $values.'(default)'
    $returnValue.Path = Remove-Argument $returnValue.MailTo 
    if ((Test-Path -Path $returnValue.Path) -eq $false)
    {
      $returnValue.hasMAPIClient = $true
    }
  }
  
  
  $returnValue
} 

Get-MAPIClient 

Here is the result:

Twitter This Tip! ReTweet this Tip!