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.
|
Do you support ASP.NET MVC 6?
Viewed 4347 times since Wed, Feb 17, 2016
How do I redirect a subdomain to a subdirectory?
Viewed 3724 times since Tue, May 1, 2012
How To Solve Problem with Connection String on EF (Entity Framework) 4 or above
Viewed 31457 times since Mon, Apr 1, 2013
I get an error Server.CreateObject Failed when I try to use CDONTs. What can I do?
Viewed 2659 times since Tue, May 1, 2012
How do I query MySQL Database in PHP ?
Viewed 3111 times since Tue, May 1, 2012
Domain Name Server (DNS) Amplification Attack
Viewed 9212 times since Wed, Oct 15, 2014
How to solve the Let’s Encrypt SSL on ASP.NET Core
Viewed 9152 times since Mon, Jul 17, 2017
Issue with Storing Session
Viewed 3441 times since Tue, Mar 24, 2015
I cannot find a way to enable ASP.NET 4.5 on my Control Panel
Viewed 10744 times since Tue, Sep 11, 2012
How to Solve the error: "405 - HTTP verb used to access this page is not allowed"?
Viewed 4755 times since Wed, Oct 24, 2018
|