вот моя использующая система:
Код: Выделить всё
using System.Net;
using System.Web;
using System.Net.Mail;
Код: Выделить всё
private void BtnEmail_Click(object sender, EventArgs e)
{
try
{
string to = "[email protected]";
string from = "[email protected]";
string subject = "Test email";
string body = @"This is a test email";
MailMessage mail = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Credentials = new NetworkCredential ("[email protected]", "myPassword");
client.Port = 587;
client.EnableSsl = true;
client.Send(mail);
MessageBox.Show("Mail Sent", "Success", MessageBoxButtons.OK);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n\n" + ex.StackTrace, "Exception");
}
}
сообщение об исключении перехвата: Ошибка отправки почты.. System.Net.Mail.SmtpException.
есть идеи, что здесь не так?? Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/196 ... mail-via-c