Отправка email с gmail аккаунта в C#

29.03.2015 at 14:15

public static void SendFromGmail(string fromAddress, string fromPassword, string toAddress, string subject, string body)
{
    var smtp = new System.Net.Mail.SmtpClient
    {
        Host = "smtp.gmail.com",
        Port = 587,
        EnableSsl = true,
        DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
        UseDefaultCredentials = false,
        Credentials = new System.Net.NetworkCredential(fromAddress, fromPassword)
    };
    using (var message = new System.Net.Mail.MailMessage(fromAddress, toAddress)
    {
        Subject = subject,
        Body = body
    })
    {
        smtp.Send(message);
    }
}


На обновления блога теперь можно подписаться Вконтакте