[英]c# Send Email using Process.Start
我想使用默认电子邮件应用程序发送不带附件的简单电子邮件。
我知道可以使用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);
您需要这样做:
SmtpClient m_objSmtpServer = new SmtpClient();
MailMessage objMail = new MailMessage();
m_objSmtpServer.Host = "YOURHOSTNAME";
m_objSmtpServer.Port = YOUR PORT NOS;
objMail.From = new MailAddress(fromaddress);
objMail.To.Add("TOADDRESS");
objMail.Subject = subject;
objMail.Body = description;
m_objSmtpServer.Send(objMail);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.