"不允许使用邮箱名称。 服务器响应为: authentication is required,smtp4,DtGowECZp2PhAI1P3TLlHg--.313S2 1334640868"
client.UseDefaultCredentials = true;
要放在
client.Credentials = new NetworkCredential("用户名", "密码");
的前面,你检查一下是否是这个原因
System.Text.Encoding encoding = System.Text.Encoding.Default;
SMTPItem s = this.si;
smtpClient.Host = s.Server;
NetworkCredential nc = new NetworkCredential();
nc.Password = s.PassWord;
nc.UserName = s.UserName;
MailMessage mm = new MailMessage();
mm.From = new MailAddress(s.SendMail, s.Sender,encoding);
mm.IsBodyHtml = false;
mm.Subject =Properties.Settings.Default.产品名称+"测试";
mm.SubjectEncoding = encoding;
mm.Body ="这是一封测试邮件";
mm.BodyEncoding = encoding;
mm.To.Add(Properties.Settings.Default.testMailAddress);
smtpClient.UseDefaultCredentials = true;//在这里加了您说的,还是出错,,请指教
smtpClient.Credentials = nc;
//smtpClient.Send(mm);
this.progressBar1.Enabled = true;
smtpClient.SendAsync(mm,new object());
smtpClient.SendCompleted += new SendCompletedEventHandler(this.SendComplete);