Home » Categories » Multiple Categories

Sample Code to Send email using ASP.NET1.1

Our mail server is configured with SMTP authentication and all your code need to use SMTP Authentication before you can send email. If your code does not use SMTP authentication, the email will not be sent.

private void Page_Load(object sender, System.EventArgs e)
{
     MailMessage mail = new MailMessage();
     mail.To = "[email protected]";
     mail.From = "[email protected]";
     mail.Subject = "this is a test email.";
     mail.Body = "Some text goes here";
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
     mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

     SmtpMail.SmtpServer = "localhost"; //your real server goes here
     SmtpMail.Send( mail );
}

Please note that you need to use localhost as the SMTP detail as there is no remote connection made between your site and our mail server.


Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to solve the Let’s Encrypt SSL on ASP.NET Core
Viewed 9922 times since Mon, Jul 17, 2017
How can I enable ASP.NET 3.5 on your Control Panel?
Viewed 4134 times since Wed, May 2, 2012
I cannot see my website. What should I do?
Viewed 4088 times since Thu, May 3, 2012
Sample Code to Send email using ASP.NET 2
Viewed 10015 times since Tue, May 1, 2012
About Azure Key Vault
Viewed 2080 times since Mon, Nov 2, 2020
Domain Name Server (DNS) Amplification Attack
Viewed 9784 times since Wed, Oct 15, 2014