问题描述
我目前使用的Process.Start我从我的WinForms应用程序发送简单的电子邮件。你能想到的任何方式来添加文件附件的电子邮件? (编辑:使用的Process.Start)
下面是我现在用的是什么:
的Process.Start(电子邮件地址:[email protected]主题=+ HttpUtility.HtmlAttributeEn code(应用程序错误报告)+&放大器;身体= +体);
尝试是这样的 - >
MailMessage theMailMessage =新MailMessage([email protected],[email protected]);
theMailMessage.Body =身体的电子邮件在这里;
theMailMessage.Attachments.Add(新的附件(pathToEmailAttachment));
theMailMessage.Subject =主题这里;
SmtpClient theClient =新SmtpClient(IP.Address.Of.Smtp);
theClient.UseDefaultCredentials = FALSE;
System.Net.NetworkCredential theCredential =新System.Net.NetworkCredential([email protected],密码);
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);
好了,根据你的编辑和其他信息,我发现这个博客由乔恩·加洛韦后, 发送通过默认的电子邮件客户端文件。
这看起来像你可能会找什么,虽然我不信奉用这种方式的任何知识,我一直用我张贴的方法。
希望这是利用你。
I am currently using Process.Start to send simple emails from my WinForms app. Can you think of any way to add a file attachment to the email? (Edit: using Process.Start?)
Here's what I use now:
Process.Start("mailto:[email protected]?subject=" + HttpUtility.HtmlAttributeEncode("Application error report") + "&body=" + body);
Try something like this -->
MailMessage theMailMessage = new MailMessage("[email protected]", "[email protected]");
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("[email protected]", "password");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);
Alright, based on your edit and additional info, I found this Blog Post by Jon Galloway, "Sending files via the default e-mail client".
This looks like what you may be looking for, though I don't profess any knowledge with this way as I have always used the method I posted.
Hopefully it is of use to you.
这篇关于发送电子邮件与附件的WinForms应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!