using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net.Mail; namespace Email_Client { public partial class Form1 : Form { public Form1() { InitializeComponent(); try { SmtpClient client = new SmtpClient(); //client.Port = 25; client.Port = 465; // client.Host = "smtp.live.com"; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("sener_email", "password"); MailMessage mm = new MailMessage("sender_email", "recipient_email ", "Subject", "Body"); mm.IsBodyHtml = true; mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(mm); label1.Text = "Message sent.."; } catch (Exception e) { label1.Text = e.ToString(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)