Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML
I have a asp.net web application on which one HTML page for contact us...
 
The contact us page contains those fields:
  • Name
  • Email
  • Message
And Finally the Submit button.
 
When I click on Submit button the form data must submitted to the given email id.
 
It works fine using Mail_to method but it opens the client side outlook which i don't want.
 
Could you give me some information about that?
 
Extra notes:
I have used server side code to send the email in lots of My project. But now my requirement is only to send the email from HTML page because my next web site is pure HTML based requirement.
 
Thanks in advance.
Posted 14-Sep-12 18:23pm
Edited 17-Sep-12 0:55am
Joan Murt81.8K
v4
Comments
_Amy at 15-Sep-12 2:10am
   
Check my updated answer. :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hii,
 
i fyou dont want to open outlook then send mail using server side language i.e. using c#.net or vb.net.
for reference follow given link
 
Send Mail / Contact Form using ASP.NET and C#[^]
  Permalink  
Comments
vithal wadje at 15-Sep-12 2:06am
   
Thanks sir but
I have used server side code to send the email in lots of My project..but now my requirement is only to send the email from HTML page because my next web site is pure HTML based requirement
Ganesh Nikam at 15-Sep-12 2:12am
   
hey dude ,
refer this article you will get your ans
 
http://stackoverflow.com/questions/7647931/sending-email-from-html-using-javascript-without-default-outlook
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hello,
You Can Attach all mail Contents in Anchor Tag with the help of Query String.
  Permalink  
Comments
vithal wadje at 15-Sep-12 4:29am
   
thanks sir give any example
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

hi..
its easy i had done for feedback form in which i am use asp page for send mail using smtp server.
.aspx page code
 
<form name ="ctrlForm" action="contact_us.asp" method="post" >
Name*<input id="Text1" type="text" name="Name" />
Email*<input id="Text2" type="text" name="Email" />
Phone*<input id="Text3"type="text"  class="input_field" name="phone" />
Message*<textarea id="Textarea1" type="text" cols="0" name="text" />
<input id="submit1" class="submit_btn" name="submit" type="submit" value="Send" >
 

 
.asp file code(contact_us.asp)
 

<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% Response.Buffer = True %>
 

<%
'Declaring Variables

 

Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Email
Dim ContactUs_Subject,ContactUs_Body,Action,IsError
Dim msg
 
On Error resume next
' Edit these 3 values accordingly.. leave the smtp server alone as it is set for Gmail
smtpserver = "smtp.gmail.com"
youremail = "test"
yourpassword = "tset"
 
' Grabbing variables from the form post
ContactUs_Name=Request.QueryString("Name")
ContactUs_Email = Request.QueryString("email")
ContactUs_Subject = Request.QueryString("phone")
ContactUs_Body = Request.QueryString("text")
Action = Request("Action")
'document.write(ContactUs_Name)
''MsgBox(ContactUs_Name,"","","","")
'ContactUs_Name = Request("ContactUs_Name")
'ContactUs_Email = Request("ContactUs_Email")
'ContactUs_Subject = Request("ContactUs_Subject")
'ContactUs_Body = Request("ContactUs_Body")
'Action = Request("Action")

    Dim strBody
 
    ' Here we create a nice looking html body for the email
    strBody = strBody & "<font face=""Arial"">Contact Us Form submitted at " & Now() &  vbCrLf & "<br><br>"
    strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") &  vbCrLf & "<br>"
    strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "<br>"
    strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr,"<br>") & "<br>"
    strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr,"<br>") & "<br>"
    strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr,"<br>") & "<br>"
    strBody = strBody & "<br>" & Replace(ContactUs_Body,vbCr,"<br>") & "<br>"
    strBody = strBody & "</font>"
 
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message")
 
    'This section provides the configuration information for the remote SMTP server.

    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'Use SSL for the connection
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
 
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = youremail
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourpassword
 
    ObjSendMail.Configuration.Fields.Update
 
    'End remote SMTP server configuration section==

    ObjSendMail.To = youremail
    ObjSendMail.Subject = ContactUs_Subject
    ObjSendMail.From =youremail   'ContactUs_Email

    ' we are sending a html email.. simply switch the comments around to send a text email instead
    ObjSendMail.HTMLBody = strBody
    'ObjSendMail.TextBody = strBody

 
    ObjSendMail.Send
 
    Set ObjSendMail = Nothing
 

if err.number=0 then
    msg="mail send successfully.see you soon"
   wscript.echo msg
    msgbox(msg)
  response.redirect "contactus.html?msg="+msg+""
else
    msg="error while sending mail"
 
   msgbox(msg)
    response.Redirect "ContactUs.html?msg="+msg+""
 
    'WScript.Echo msg
End if
 
' Used to check that the email entered is in a valid format
Function IsValidEmail(Email)
    Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserName,DomainName,atChr,tAry1
    ValidFlag = False
        If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
            atCount = 0
            SpecialFlag = False
            For atLoop = 1 To Len(Email)
            atChr = Mid(Email, atLoop, 1)
                If atChr = "@" Then atCount = atCount + 1
                If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
                If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
                If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
                If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
            Next
            If (atCount = 1) And (SpecialFlag = False) Then
                BadFlag = False
                tAry1 = Split(Email, "@")
                UserName = tAry1(0)
                DomainName = tAry1(1)
            If (UserName = "") Or (DomainName = "") Then BadFlag = True
            If Mid(DomainName, 1, 1) = "." then BadFlag = True
            If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
                ValidFlag = True
            End If
        End If
        If BadFlag = True Then ValidFlag = False
        IsValidEmail = ValidFlag
End Function
%>
 
<html>
 
<head>
<title>Contact Us Form ( Powered By Code From www.CJWSoft.com )</title>
</head>
 
<body style="font-family: Arial; font-size: 12px">
 
<%
If Action = "SendEmail" Then
 
    ' Here we quickly check/validate the information entered
    ' These checks could easily be improved to look for more things
    If IsValidEmail(ContactUs_Email) = "False" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a valid email address.</font><br>")
    End If
 
    If ContactUs_Name = "" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Name.</font><br>")
    End If
 
    If ContactUs_Subject = "" Then
    IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Subject.</font><br>")
    End If
 
    If ContactUs_Body = "" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Body.</font><br>")
    End If
 
End If
 

%>
<font size="2">Your message as seen below has been sent. Thank You !!
<br><br>
<font color="blue">
<% =Replace(ContactUs_Body,vbCr,"<br>") %>
</font>
</font>
<% Else %>
 
<form action="contact_us.asp" method="POST">
<input type="hidden" name="Action" value="SendEmail">
 

</form>
 
<% End If %>
</body>
 
</html>
  Permalink  
Comments
Callijah at 3-Jan-14 10:53am
   
I am a coding beginner, what do I do with each of the sections you have posted? I used the first in a simple HTML box for our website. What do I do with the larger portion? Thank You.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 514
1 Gihan Liyanage 298
2 RyanDev 268
3 Sergey Alexandrovich Kryukov 223
4 Richard Deeming 185
0 Sergey Alexandrovich Kryukov 8,936
1 OriginalGriff 7,891
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100