Send Mail Using C#

To send a mail using you need two namespaces which are
1. Using System.Net;
2. Using System.Net.Mail;
Here I have taken three textbox for getting To-email address , subject, Body or you can place them with a string in double quotes.

   If you are getting error sc.send(msg) means your Gmail account rejecting your access from other apps( rectify this you need to do changes in your Gmail account settings.
1.Open your Gmail account settings->sign & security-> at down you will find option called allow less secure app access: OFF now make that to ON and debug the application and after that you can check your Gmail send items.
Author :


Priti Kumari

I am technical blogger.I blogs at and


  1. Valuable for information if there is any other regarding this kindly revert me back on this Application Company

  2. Hi,
    Thanks for sharing the info about ASP .NET Plz keep sharing on...
    Thank you...