You must Sign In to post a response.
  • Category: HTML

    How to send a mail through contact us page in webpage

    i am developed a website for a company using html,css,javascript,jquery i am not using any database and any programming language like php,asp,or java.i created one contact us page for the customers like

    Name: xxx
    email: ramy@xy.com
    message: test message

    submit button and clear

    once i fill the form ,i want to submit the form.once i clicked the submit button i want that entered name,email,and message to my email inbox.how can i do this ..pls help me.
  • #746771
    Hi,
    You need to use the Mail:To keyword for achieving the task,please find the lines below

    <form action="MAILTO:someone@example.com" method="post" enctype="text/plain">
    Name:<br>


    All is well.
    Thanks,
    Dharma
    Editor,Mentor,MVM
    Try and fail but don't fail and try

  • #746785
    Call the below java script method on the Submit button of the Contact Us page. This is a plain java script code.



    function sendEMail()
    {
    var EmailLink = "mailto:Anil@abc.com"+
    "?cc=cc@abc.com"+
    "&subject=" + escape("hi There")+
    "&body=" + escape("This is Contact us");
    window.location.href = link;
    }

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #754766
    Hi ramya,

    If you are creating website in asp.net
    then you can use this code on submit button click event in c#.

    Using System.Net;//namespace
    public void SendMail()
    {
    Email.Text = "Thank you for contacting us.!";

    MailMessage mailmesssage = new MailMessage();
    mailmesssage.From = new MailAddress("username@gmail.com", "Your Name");
    mailmesssage.To.Add(txtemail.Text);
    mailmesssage.Subject = "Subject";
    mailmesssage.Body = Email.Text;

    //G-mail settings
    try
    {
    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
    smtpClient.Port = 25;
    smtpClient.Credentials = new NetworkCredential("username@gmail.com", "password");
    smtpClient.EnableSsl = true;
    smtpClient.Send(mailmesssage);
    }
    catch (Exception ex)
    {
    Response.Write("An error occured during sending email: " + ex.Message);
    }

    to get an email in your inbox:
    string myemailid = username@gmail.com //domain can be anything gmail or hotmail

    Email.Text = "Name: xxx";
    Email.Text = "Email: ramy@xy.com";
    Email.Text = "Message: test message";

    MailMessage mailmesssage = new MailMessage();
    mailmesssage.From = new MailAddress("username@gmail.com", "Your Name");
    mailmesssage.To.Add(myemailid);
    mailmesssage.Subject = "Subject";
    mailmesssage.Body = Email.Text;

    //G-mail settings
    try
    {
    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
    smtpClient.Port = 25;
    smtpClient.Credentials = new NetworkCredential("username@gmail.com", "password");
    smtpClient.EnableSsl = true;
    smtpClient.Send(mailmesssage);
    }
    catch (Exception ex)
    {
    Response.Write("An error occured during sending email: " + ex.Message);
    }
    }
    }

    Nirav Lalan,
    .NET Developer
    IT has no ends

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."


  • Sign In to post your comments