| Home » Categories » Multiple Categories |
Sample Code to Send email using ASP.NET1.1 |
|
Article Number: 83 | Rating: Unrated | Last Updated: Tue, May 1, 2012 at 11:11 PM
|
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 );
}
|
Attachments
There are no attachments for this article.
|
How do I query MySQL database in ASP.NET?
Viewed 12957 times since Tue, May 1, 2012
My site is showing 500 Internal Server error message. What is wrong here?
Viewed 3945 times since Thu, May 3, 2012
Issue with Storing Session
Viewed 4143 times since Tue, Mar 24, 2015
I cannot see my website. What should I do?
Viewed 4148 times since Thu, May 3, 2012
How do I send an email from my ASP.NET website by using SMTP Authentication?
Viewed 6893 times since Tue, May 1, 2012
About Azure Key Vault
Viewed 2164 times since Mon, Nov 2, 2020
My application pool stops working. What is wrong with my site?
Viewed 13657 times since Sun, Feb 15, 2015
HTTP Error 502.5 - Process Failure error message when publishing an ASP.NET Core Website
Viewed 11226 times since Mon, Mar 27, 2017
Do you allow custom COM components?
Viewed 3239 times since Tue, May 1, 2012
How to Deploy and host .Net Core 2 and Angular 6 app
Viewed 13719 times since Tue, Oct 23, 2018
|
