本文介绍了c#使用Process.Start发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to send simple email with no attachment using default email application.

我知道可以使用Process.Start完成,但是我无法让它工作。这是我到目前为止:

I know it can be done using Process.Start, but I cannot get it to work. Here is what I have so far:

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消息与预先写的文本。我想直接发送这个没有用户手动点击发送按钮。我缺少什么?

But it simply opens Outlook message with pre-written text. I want to directly send this without having user to manually click "Send" button. What am I missing?

谢谢

推荐答案

这样做:

            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);

这篇关于c#使用Process.Start发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:35