下面是我最近用C#写的一个邮件发送程序:
首先在程序开头添加引用:
using System.Web.Mail;
程序主体部分:
MailMessage mailMessage = new MailMessage();
mailMessage.To =(收件人的EMAIL地址);
mailMessage.From=(发件人的EMAIL地址);
mailMessage.Body=(邮件的内容,可以是HTML文件);
mailMessage.Subject="(邮件标题!)";
mailMessage.BodyFormat = MailFormat.Html ;(说明发送的是HTML代码)
string strMailName ="(发件人的用户名)";
string strPassWord="(发件人的密码)";
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" ); //认证类型
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", strMailName ); //认证用户名
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", strPassWord ); //认证密码
string smtpServer = (SMTP服务器地址如218.108.36.229);
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send( mailMessage );
经本人测试通过!