2

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?

4

1 回答 1

0

感谢您的回答和评论。

这里是对问题的一个小更新,可能是解决方案(我仍然不完全确定问题是什么):我可以将问题重现到我测试过的部门的每台计算机上(而不仅仅是我的问题中提到的两台)。几天后,我注意到一切都恢复正常了。我没有更改程序的代码,也没有停用防病毒软件。

我在我的问题中没有提到(我认为这并不重要),所有计算机都是新的。我认为这可能是问题所在:Windows 有一个索引服务,我可以想象一开始,可能需要几天时间才能扫描整个计算机。在这种情况下,搜索默认邮件管理器可能需要很长时间,但是一旦索引服务完成了他的工作,搜索默认邮件管理器就会再次快速。

于 2016-11-26T10:10:20.490 回答