Skip to main content
 首页 » 编程设计

c# 使用 Process.Start 发送电子邮件

2024年01月22日31xing901022

我想使用默认电子邮件应用程序发送没有附件的简单电子邮件。

我知道可以使用 Process.Start 来完成,但我无法让它工作。这是我目前所拥有的:

string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "to@user.com", "Subject of message", "This is a body of a message"); 
System.Diagnostics.Process.Start(mailto); 

但它只是打开带有预先编写文本的 Outlook 邮件。我想直接发送,而无需用户手动单击“发送”按钮。我错过了什么?

谢谢

请您参考如下方法:

你需要这样做:

string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "to@user.com", "Subject of message", "This is a body of a message"); 
mailto = Uri.EscapeUriString(mailto); 
System.Diagnostics.Process.Start(mailto);