Send Email from asp.net

By Super Man

here i am showing how to send email from asp.net 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);

        try

        {

 

            smtp.Send(msgMail);

        }

        catch (Exception exp)

 

        {

            // error handling

        }

 

Send Email from asp.net  (1286 Views)