Hello people, i need your help here;I want to use this code on asp.net application that has seperate files "Contactus.aspx and Contactus.aspx.cs" please how do i arrange these codes.
<%@ 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("postmaster@HostingAccountDomain.com");
mail.To.Add("postmaster@HostingAccountDomain.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "This is from system.net.mail using C sharp with smtp authentication.";
//send the message
SmtpClient smtp = new SmtpClient("mail.HostingAccountDomain.com");
NetworkCredential Credentials = new NetworkCredential("postmaster@HostingAccountDomain.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>
</html>