This topic includes the sample code to send email from ASP.Net using C# code :
Sample Code :
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>
Â
<script language="C#" runat="server">
   protected void Page_Load(object sender, EventArgs e)
   {
      //create the mail message
       MailMessage mail = new MailMessage();
Â
       //set the addresses
       mail.From = new MailAddress("yourname@yourdomain.com");
       mail.To.Add("recipient_email@domain.com");
      Â
       //set the content
       mail.Subject = "This is a test email from C# script";
       mail.Body = "This is a test email from C# script";
       //send the message
        SmtpClient smtp = new SmtpClient("smtp.yourdomain.com");
        Â
        NetworkCredential Credentials = new NetworkCredential("smtp@yourdomain.com", "password");
        smtp.Credentials = Credentials;
        smtp.Send(mail);
        lblMessage.Text = "Mail Sent";
   }
</script>
<html>
<body>
   <form runat="server">
       <asp:Label id="lblMessage" runat="server"></asp:Label>
   </form>
</body>
Note :-Â You will require to make some changes in your script like SMTP server, email address & password etc.
Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com
Most Popular Articles
How to use Dundas Mailer?
A. Sending an Email with the QuickSend Method <% Dim objMailer 'Mailer control Set...
How to send email through CDONTS Email?
CDONTS stands for "Collaboration Data Objects for Windows NT Server" and as the name suggests it...
How to send emails through JMail?
We have installed JMail on our Windows shared servers. You can use following sample script to...
How to use ASPSMS?
Here is the ASP VB-Script example, intended to be used on an IIS (Internet Information Server)...
How to use Dundas Upload?
Dundas upload control is a flexible and reliable component allows you to accept, save, and...
Powered by WHMCompleteSolution