Submit a Ticket
Support Center » Knowledgebase » Send email with smtp authentication using ASP.NET

Send email with smtp authentication using ASP.NET

Send email with smtp authentication using ASP.NET

Following Codes demonstrates how to send an email with SMTP Authentication using ASP.NET:

       //create the mail message

        MailMessage mail = new MailMessage();

        //set the addresses
        mail.From = new MailAddress("[email protected]"); //IMPORTANT: This must be same as your smtp authentication address.
        mail.To.Add("[email protected]");

        //set the content
        mail.Subject = "This is an email";
        mail.Body = "This is from system.net.mail using C sharp with smtp authentication.";
        //send the message
         SmtpClient smtp = new SmtpClient("mail.yourdomain.com");

        //IMPORANT:  Your smtp login email MUST be same as your FROM address.
         NetworkCredential Credentials = new NetworkCredential("[email protected]", "password");
         smtp.Credentials = Credentials;
         smtp.Send(mail);
         lblMessage.Text = "Mail Sent";


 


 This answer was helpful  This answer was not helpful
 Back