.net发邮件出现的问题
程序:
MyMail = new MailMessage();
MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0");
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", txtUserName.Text.Trim());
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtPassword.Text.Trim());
MyMail.Subject = this.txtTitle.Text.Trim();
MyMail.From = this.txtMail.Text.Trim();
MyMail.Body = this.txtContent.Text.Trim();
MyMail.BodyFormat = MailFormat.Text;
MyMail.Priority = MailPriority.High;
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(MyMail);
MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0");
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", txtUserName.Text.Trim());
//MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtPassword.Text.Trim());
MyMail.Subject = this.txtTitle.Text.Trim();
MyMail.From = this.txtMail.Text.Trim();
MyMail.Body = this.txtContent.Text.Trim();
MyMail.BodyFormat = MailFormat.Text;
MyMail.Priority = MailPriority.High;
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(MyMail);
解决方法:
确定之后重新启动smtp