What would cause Process.Start to crash the app with a mailto: address?

-1

Not sure why this is, but the following line crashes our WPF app...

Process.Start("mailto:example@stackoverflow.com");

Here's the exception:

System.ComponentModel.Win32Exception
  HResult=0x80004005
  Message=The system cannot find the file specified.
  Source=System.Diagnostics.Process
  StackTrace:
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)

Note: There is no 'InnerException' reported.

I've confirmed that a mail handler is properly registered by writing this simple HTML file with a mailto: hyperlink to test...

<html>
    <body>
        <a href="mailto:example@stackoverflow.com">example@stackoverflow.com</a>
    </body>
</html>

You click the link and the mail client opens right up as expected!

Per another post here on the site, I also tried the Blend Interactions method by importing this...

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"

Then using it like this...

<Label Content="Send Email">
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseLeftButtonUp">
      <ei:LaunchUriOrFileAction Path="mailto:example@stackoverflow.com" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</Label>

but I get the same exception.

So what could be causing this?

c#
wpf
url
mailto
process.start

1 Answer

1

Try Setting UseShellExecute:

System.Diagnostics.Process.Start(new ProcessStartInfo("mailto:example@stackoverflow.com") { UseShellExecute = true });

User contributions licensed under CC BY-SA 3.0