0

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>
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by ckchaudhary
0

i've compliled a list of functions(and their overloads) to send emails (with or without multiple file attachements) into a single dll which is available for download here here . you may find it useful

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.