using(SmtpClient client = new SmtpClient("smtp.gmail.com", 587))
{
// Configure the client
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(textBox1.Text, textBox3.Text);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage message = new MailMessage(
textBox1.Text, // From field
textBox2.Text, // Recipient field
textBox4.Text, // Subject of the email message
richTextBox1.Text // Email message body
);
client.Send(message);
MessageBox.Show("Email has been sent.");
}
Error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
使用Gmail SMTP從CSHARP/.NET
發送郵件我已經收到此錯誤與Gmail,但我能夠使用其他SMTP服務器來發送郵件。憑據是正確的。
閱讀此鏈接: http://email.about.com/od/gmailtips/qt/How-To-Unlock-Gmail-For-A-New-Email-Program-Or-Service.htm – 2015-03-25 09:08:11
選中此。 http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp – 2015-03-25 09:08:29
@ZoharPeled鏈接工作,我能夠發送郵件..謝謝 – sooraj 2015-03-25 09:14:30