Runtime: System.Diagnostic.Process.Start(...) does not Support mailto: protocoll

Created on 19 Jul 2019  路  4Comments  路  Source: dotnet/runtime

Porting a .Net Framework App to .Net Core 3.0, I was not able to invoke the default mail client with the mailto: protocoll using System.Diagnostics.Process.Start(...).

.Net Core 3.0.100-preview5-011568
Windows 10 1809
Outlook 2016

Sampe code to reproduce

```c#
var body = "This is a body of a message";
var recipients = String.Join(",", "[email protected]", "[email protected]");
string mailto = $"mailto:{recipients}?Subject={"Subject of message"}&Body={body}";
mailto = Uri.EscapeUriString(mailto);
System.Diagnostics.Process.Start(mailto);

```

The Exception that occures: System.ComponentModel.Win32Exception: 'Das System kann die angegebene Datei nicht finden.' (Translated System can not find the file not sure if that is the actuall english error message)

area-System.Diagnostics.Process

Most helpful comment

undocumented

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute

"The default is true on .NET Framework apps and false on .NET Core apps."

Undocumented in terms of "not mentioned in the 'how to port your framework app to dot net core'" blog posts. In terms of "no red banner in the Process.Start docs". The sentence you quote is not highlighted and only exists in the docs of UseShellExecute.

So yes, its documented. But also yes that it's pretty much unclear for most .NET Framework developers when porting their apps until they experience the issue and hopefully use the search function to figure it out. This is not the first "issue" about it and it will likely not be the last.

All 4 comments

In .NET Core the useshellexecute is set to false while in .NET Framework it's set to true. This is an undocumented breaking change. When porting .NET Framework to .NET Core you have to explicitly use ProcessStartInfo

System.Diagnostics.Process.Start(new ProcessStartInfo(mailto) { UseShellExecute = true });

undocumented

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute

"The default is true on .NET Framework apps and false on .NET Core apps."

undocumented

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute

"The default is true on .NET Framework apps and false on .NET Core apps."

Undocumented in terms of "not mentioned in the 'how to port your framework app to dot net core'" blog posts. In terms of "no red banner in the Process.Start docs". The sentence you quote is not highlighted and only exists in the docs of UseShellExecute.

So yes, its documented. But also yes that it's pretty much unclear for most .NET Framework developers when porting their apps until they experience the issue and hopefully use the search function to figure it out. This is not the first "issue" about it and it will likely not be the last.

Closing, since this seems to be by design.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aggieben picture aggieben  路  3Comments

jamesqo picture jamesqo  路  3Comments

matty-hall picture matty-hall  路  3Comments

Timovzl picture Timovzl  路  3Comments

iCodeWebApps picture iCodeWebApps  路  3Comments