TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prasad Bhagat
NA
516
237.3k
How to implement contactus form in html?
Apr 16 2016 12:13 PM
Dear All,
iam looking for create a page in hml for contact us ..
after designing i dont know how to write a script for send mail to mail id .please help
Reply
Answers (
5
)
0
Rahul Chavan
0
912
138.4k
Apr 16 2016 10:06 PM
Prasad
Pure html code will not allow you to send email.
You need SMTP for sending email or you need to embed php in javascript(it is not a good practice).
You can call server method on your form action.
0
Prasad Bhagat
0
516
237.3k
Apr 16 2016 1:58 PM
Hi Manas, Not Exactly AM just implementing with .html page only.. i have html controles and now i click the submit button then i want to send it to mail .
0
Manas Mohapatra
89
20.4k
16.7m
Apr 16 2016 1:48 PM
Then you can use AJAX.
If you are using jQuery then use $.ajax().
Conversely if you are using only Javascript then you can implement XMLHttpRequest object. Follow below link:
http://www.c-sharpcorner.com/UploadFile/manas1/implementing-ajax-concept-in-Asp-Net-using-xmlhttprequest/
0
Prasad Bhagat
0
516
237.3k
Apr 16 2016 1:39 PM
Dear Manas , am Asking for html with java script .
0
Manas Mohapatra
89
20.4k
16.7m
Apr 16 2016 1:19 PM
First design your "contact us" page. Follow below links:
http://www.webdesignerdepot.com/2013/03/20-excellent-contact-pages/
http://www.awwwards.com/25-impressive-contact-forms.html
Follow below link how it is implemented in ASP.NET
http://www.codersbarn.com/post/2008/11/30/ASPNET-Contact-Form.aspx
If you want to make ContactUs page as *.html , *.aspx then you need to follow below steps.
Add following code in HTML page:
<
form
method
=
"post"
action
=
"contactus.aspx"
>
Email:
<
input
type
=
"text"
name
=
"toEmail"
/>
<
br
/>
Subject:
<
textarea
name
=
"message"
>
</
textarea
>
<
br
/>
<
input
type
=
"button"
text
=
"Send"
/>
</
form
>
Next in code behind page contactus.aspx.cs, add below code:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(Request.Form.Count > 0)
{
string
formEmail =
""
;
string
fromEmail =
"from@email.com"
;
string
defaultEmail =
"default@email.com"
;
string
sendTo1 = Request.Form.Keys[
"toEmail"
];
int
x = 0;
System.Net.Mail.MailMessage myMsg =
new
System.Net.Mail.MailMessage();
SmtpClient smtpClient =
new
SmtpClient();
try
{
myMsg.To.Add(
new
System.Net.Mail.MailAddress(defaultEmail));
myMsg.IsBodyHtml =
true
;
myMsg.Body = formEmail;
myMsg.From =
new
System.Net.Mail.MailAddress(fromEmail);
myMsg.Subject =
"Sent using Gmail Smtp"
;
smtpClient.Host =
"smtp.gmail.com"
;
smtpClient.Port = 587;
smtpClient.EnableSsl =
true
;
smtpClient.UseDefaultCredentials =
true
;
smtpClient.Credentials =
new
System.Net.NetworkCredential(
"testing@gmail.com"
,
"pward"
);
smtpClient.Send(defaultEmail, sendTo1,
"Sent using gmail smpt"
, formEmail);
}
catch
(Exception ee)
{
debug.Text += ee.Message;
}
}
}
Rest Web API in .Net
How to consume WCF (using webHttpbinding) JSON in a asp web