简体   繁体   English

无法打开默认邮件客户端

[英]unable to open the default mail client

I am using following code to open the default mail client 我正在使用以下代码打开默认邮件客户端

using (Process mailProcess = new Process())
{
     ProcessStartInfo processInfo = new ProcessStartInfo();
     processInfo.FileName = string.Format(CultureInfo.InvariantCulture, 
                            "mailto:{0}?subject={1}&body={2}", 
                             sendToAddress.Address, subject, message);
     processInfo.UseShellExecute = true;
     processInfo.WindowStyle = ProcessWindowStyle.Normal;
     mailProcess.StartInfo = processInfo;
     Process.Start(processInfo);
}

It starts the process but doesn't show mail client. 它启动该过程,但不显示邮件客户端。 Actually when I am using only localhost it doesn't open the mail client although it starts the process. 实际上,当我仅使用localhost时,尽管启动了进程,但它没有打开邮件客户端。

When I am using localhost: it works. 当我使用本地主机时:有效。

Can anybosy hel me? 有人可以帮我吗?

According to this you need to make sure that you URL-encode the file name. 根据此,您需要确保对文件名进行URL编码。 It may not contain spaces or other special characters not available in URLs. 它不能包含URL中不可用的空格或其他特殊字符。

Is suspect that your subject and body at least contain spaces or newlines. 怀疑您的主题和身体至少包含空格或换行符。 You can use HttpUtility.UrlEncode for this task. 您可以使用HttpUtility.UrlEncode来完成此任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM