Send Email from

By Super Man

here i am showing how to send email from using System.Net.Mail


using System.Net.Mail;




        String userName = "your username";

        String passWord = "your password";

        String sendr = "your email id";

        String recer = "receiver of email";

        String subject = "subject of email";

        String body = "body part of email";


        MailMessage msgMail = new MailMessage(sendr, recer, subject, body);


        int PortNumber = 587; // port number

        SmtpClient smtp = new SmtpClient("smtpservername", PortNumber);

        msgMail.IsBodyHtml = true;
// if your body contains html tag

smtp.EnableSsl = true;

        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

        smtp.Credentials = new System.Net.NetworkCredential(userName, passWord);






        catch (Exception exp)



            // error handling



Send Email from  (1286 Views)