从WinForms应用程序发送带附件的电子邮件?

我目前正在使用Process.Start从我的WinForms应用程序发送简单的电子邮件。 您能想到以任何方式向电子邮件添加文件附件吗? (编辑:使用Process.Start?)

这是我现在使用的:

Process.Start("mailto:test@test.invalid?subject=" + HttpUtility.HtmlAttributeEncode("Application error report") + "&body=" + body); 

尝试这样的事情 – >

 MailMessage theMailMessage = new MailMessage("from@email.com", "to@email.com"); theMailMessage.Body = "body email message here"; theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment")); theMailMessage.Subject = "Subject here"; SmtpClient theClient = new SmtpClient("IP.Address.Of.Smtp"); theClient.UseDefaultCredentials = false; System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("user@name.com", "password"); theClient.Credentials = theCredential; theClient.Send(theMailMessage); 

好的,根据你的编辑和其他信息,我发现Jon Galloway撰写的这篇博文, “通过默认的电子邮件客户端发送文件” 。

这看起来像你可能正在寻找的东西,虽然我不会以这种方式表达任何知识,因为我一直使用我发布的方法。

希望它对你有用。