MailMessage msg = new MailMessage();
msg.To.Add(“收件人心想”);
msg.From = new MailAddress("发件人邮箱", "发件人", System.Text.Encoding.UTF8);
msg.Subject = "主题";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = “内容”;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High; //Add the Creddentials
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("用户名", "密码");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.Host = "stmp.gmail.com";
//client.EnableSsl = true;
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
object userState = msg;
try
{
//you can also call client.Send(msg)
client.Send(msg);
}
catch (System.Net.Mail.SmtpException ex)
{
MessageBox.Show(ex.Message, "Send Mail Error");
}
我这样写有什么问题吗?为什么发送不了?报错说是:
Syntax error, command unrecognized. The server response was: sender must be equal to authentication user required (#5.7.1)请大家帮帮忙
msg.To.Add(“收件人心想”);
msg.From = new MailAddress("发件人邮箱", "发件人", System.Text.Encoding.UTF8);
msg.Subject = "主题";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = “内容”;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High; //Add the Creddentials
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("用户名", "密码");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.Host = "stmp.gmail.com";
//client.EnableSsl = true;
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
object userState = msg;
try
{
//you can also call client.Send(msg)
client.Send(msg);
}
catch (System.Net.Mail.SmtpException ex)
{
MessageBox.Show(ex.Message, "Send Mail Error");
}
我这样写有什么问题吗?为什么发送不了?报错说是:
Syntax error, command unrecognized. The server response was: sender must be equal to authentication user required (#5.7.1)请大家帮帮忙
应该是你的这个不能通过 gmail服务器的验证