I'm currently using this method and it works perfectly:
public static void CreateEmailInDefaultMailEditor(string to, string subject, string body)
{
Process.Start($"mailto:{to}?subject={subject}&body={body}");
}
I then tried it on another computer and its also working there but it's VERY slow (more that one minute to open my mail editor!).
I debugged the Process.Start
(in System.dll) method and found out that the problem was at the end the NativeMethod.ShellExecuteEx
method that runs very slowly.
I also noticed that specifying the name of the program that should open to send the email
public static void CreateEmailInOutlook(string to, string subject, string body)
{
Process.Start("outlook.exe", $"mailto:{to}?subject={subject}&body={body}");
}
solves the problem but that does not explain why it's working correctly on a computer and not on the other and it doesn't do the same thing: not specifing the program automatically opens the default one.
So the question is quite simple: Why this behavior and how to workaround it?