string msgSubject = txtSubject.Text.Trim(); string FrommailId = txtFrom.Text.ToString(); string TomailId = txtTo.Text.ToString(); string mailPassword = "password"; string mailServer = txtMailServer.Text.Trim(); System.Net.Mail.MailMessage objMessage = new MailMessage(); objMessage.To.Add(TomailId);//Set To address objMessage.From = new MailAddress(FrommailId, "From", System.Text.Encoding.UTF8);//Set From address objMessage.Subject = msgSubject;//Set Subject objMessage.SubjectEncoding = System.Text.Encoding.UTF8; objMessage.Body = txtMessage.Text.Trim(); objMessage.BodyEncoding = System.Text.Encoding.UTF8; objMessage.IsBodyHtml = false; objMessage.Priority = MailPriority.High; SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential(FrommailId, mailPassword);//Set UserName and Password for Network authendication client.Port = Convert.ToInt32(txtPortNo.Text.Trim());//Port for sending mail client.Host = mailServer;//587 For smtp.gmail.com client.EnableSsl = true; client.Send(objMessage);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)