Header Ads Widget

Responsive Advertisement

Send Email using C# .Net or ASP .Net example with source code


In this lecture we learn about:

  • Who Send Email?
  • Who give email header?
  • Who get email address of receiver as input?
  • Who get message from input textbox?
  • Who send email using Gmail SMTP server or Hotmail SMTP Server or other servers?
  • Who sure the credentials for email sending? 

Note: First of all if you use gmail smtp server for sending email  enable the Less Secure Apps.

=> Instructions given in code by using comments.

Source Code:

--Create Button Click Event 

        private void button1_Click(object sender, EventArgs e)
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                //Email Address of Receiver
                //Subject of Email
                message.Subject = "Welcome Email Sending Demo";
                //Email of Sender and Header Text
                message.From = new System.Net.Mail.MailAddress("example@gmail.com","Text Show On Header");
                //Message you want send
                message.Body = textBox2.Text.Trim();
                //SMTP address for Gmail=> smtp.gmail.com , Hotmail=> smtp.live.com , For other servers use related address
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
                //Email and Password of Sender
                smtp.Credentials = new System.Net.NetworkCredential("example@gmail.com", "Password");
                //SSL Security Enable
                smtp.EnableSsl = true;
                MessageBox.Show("Email Send Successfully");
            catch (Exception)

Use Mobile Phone and Scan for direct access to link on mobile phone.

Post a Comment