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 = "me@mycompany.com";
mail.From = "you@yourcompany.com";
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 to solve the Let’s Encrypt SSL on ASP.NET Core
Viewed 9543 times since Mon, Jul 17, 2017
How to Solve the error: "405 - HTTP verb used to access this page is not allowed"?
Viewed 5275 times since Wed, Oct 24, 2018
My website session times out earlier than expected. Why?
Viewed 4946 times since Tue, May 1, 2012
About Azure Key Vault
Viewed 1703 times since Mon, Nov 2, 2020
How do I redirect a subdomain to a subdirectory?
Viewed 4025 times since Tue, May 1, 2012
How to Solve an Error Message "Validation of viewstate MAC failed"
Viewed 9353 times since Tue, Apr 2, 2013
Do you allow custom COM components?
Viewed 2865 times since Tue, May 1, 2012
Issue with Storing Session
Viewed 3772 times since Tue, Mar 24, 2015
How do I send an email from my ASP.NET website by using SMTP Authentication?
Viewed 6496 times since Tue, May 1, 2012
I receive this error message: "Directory Listing Denied. This Virtual Directory does not allow contents to be listed."
Viewed 10598 times since Mon, Apr 30, 2012
|