• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

web form email without a mail client

I would like to build a web form and then allow them to submit this application. but i am confused on how the information would get sent to an email address, even though the machine it would be browsed on would not have an email client on it.   thank you
0
nexcool
Asked:
nexcool
  • 2
1 Solution
 
pkaledaCommented:
You can create a form that passes the form data to a page on your server.  You can then create a script in asp, php, perl to send the email from your server.  There are many ways to do this.

I can provide an example if I know your server OS and webserver software.  I use ASP to compile the form data and send it to CDONTs on an IIS machine.

PK
0
 
nexcoolAuthor Commented:
It would be windows 2000 server or 2003
0
 
pkaledaCommented:
OK.  Here is your collection page in a simple form.  I have built this using cdonts that is on all windows 2000 systems.  This can be modified to use cdosys for 2003 server, or you can just copy the cdonts.dll from the 2000 to the 2003 box and register it.  

Form.asp

<HTML>
<FORM method='post' action='sendmail.asp'>
Email:<INPUT TYPE="text" NAME="email">
Name:<INPUT TYPE="text" NAME="Name">
<INPUT TYPE="submit">
</FORM>
</HTML>


SendMail.asp

<%
  Dim MyBody
  Dim MyCDONTSMail
  Dim email
  Dim name

name=Trim(Request.Form("Name"))
email=Trim(Request.Form("email"))

Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From="webmaster@yourdomain.com"
MyCDONTSMail.To= email
MyCDONTSMail.Bcc="webmaster@yourdomain.com"
MyCDONTSMail.Subject="Email Subject"
MyBody = "Dear " &Name&"," &VbCrLf
MyBody = MyBody & " " &VbCrLf
MyBody = MyBody & "Here is line one of the body."&VbCrLf
MyBody = MyBody & " " &VbCrLf
MyBody = MyBody & "Your email is: " & email &VbCrLf
MyBody = MyBody & " " &VbCrLf
MyBody = MyBody & "Sincerely," &VbCrLf
MyBody = MyBody & " " &VbCrLf
MyBody = MyBody & "Webmaster " &VbCrLf
MyCDONTSMail.body= MyBody
MyCDONTSMail.send
set MyCDONTSMail=nothing
%>

That is it.  You can add html code to the sendmail.asp page, or code to write info to a database as well.  

PK
0
 
Lord_McFlyCommented:
The following example uses just a single page and has minor validation on the To, From, Subject & Meesage fields - once the email is sent it returns to the form with a message 'Message sent'

The page can be copied and pasted and works 'as is'

==========================================================================================================================
<%@ Language=VBScript %>
<%Option Explicit%>
<%
Dim objMail
Dim sForm(3), sErrMsg, sBody
Dim iLp

If Request.Form("Button") = "Send" then
      sErrMsg = ""
      
      For iLp = 0 to 3
            sForm(iLp) = Trim(Request.Form("f_"&iLp))
      Next
      
      If sForm(0) = "" then
            sErrMsg = "ERROR: To - required."
      Else
            If sForm(1) = "" then
                  sErrMsg = "ERROR: From - required."
            Else
                  If sForm(2) = "" then
                        sErrMsg = "ERROR: Subject - required."
                  Else
                        If sForm(3) = "" then
                              sErrMsg = "ERROR: Message - required."
                        End If
                  End If
            End If
      End If
      
      If sErrMsg = "" then
            sBody = ""
            sBody = sBody & "<!DOCTYPE HTML PUBLIC '-//IETF//DTD HTML//EN'>"
            sBody = sBody & "<html>"
            sBody = sBody & "<head>"
            sBody = sBody & "<title>Message...</title>"
            sBody = sBody & "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
            sBody = sBody & "</head>"
            sBody = sBody & "<body>"
            sBody = sBody & "<font face='Verdana' size='2' color='#000000'>"
            sBody = sBody & "You have received a message:<br><br>"
            sBody = sBody & "The Message:<br>"
            sBody = sBody & "================================================<br>"
            sBody = sBody & "<b>" & sForm(3) & "</b>"
            sBody = sBody & "</font>"
            sBody = sBody & "</body>"
            sBody = sBody & "</html>"
            
            'If using CDONTS to send emails then uncomment
            '================================================================
            Set objMail = Server.CreateObject("CDONTS.NewMail")
            objMail.BodyFormat = 0
            objMail.MailFormat = 0
            objMail.Body = sBody
            
            'If using CDOSYS to send emails then uncomment
            '================================================================
            'Set objMail = Server.CreateObject("CDO.Message")
            'objMail.HTMLBody = sBody
            
            'Common for both CDONTS & CDOSYS...
            '================================================================
            objMail.To = sForm(0)
            objMail.From = sForm(1)
            objMail.Subject = sForm(2)
            objMail.Send
            
            For iLp = 0 to 3
                  sForm(iLp) = ""
            Next
            
            sErrMsg = "NOTICE: Message sent."
      End If
End If

%>
<html>
<head>
<title>Email</title>
</head>
<body>
<form name="Email" method="post" action="">
<table  width="400" cellspacing="0" cellpadding="2" border="1">
      <tr>
            <td colspan="3" height="30" align="center"><b>MESSAGE CENTRE</b></td>
      </tr>
      <%If sErrMsg <> "" then%>
            <tr>
                  <td colspan="3" height="25"><%=sErrMsg%></td>
            </tr>
      <%End If%>
      <tr>
            <td width="100" height="25">To:&nbsp;</td>
            <td colspan="2">
                  <input type="text" name="f_0" size="29" value="<%=sForm(0)%>">
            </td>
      </tr>
      <tr>
            <td height="25">From:&nbsp;</td>
            <td colspan="2">
                  <input type="text" name="f_1" size="29" value="<%=sForm(1)%>">
            </td>
      </tr>
      <tr>
            <td height="25">Subject:&nbsp;</td>
            <td colspan="2">
                  <input type="text" name="f_2" size="33" value="<%=sForm(2)%>">
            </td>
      </tr>
      <tr>
            <td colspan="3" height="25">Message:</td>
      </tr>
      <tr>
            <td colspan="3">
                  <textarea rows="6" name="f_3" style="WIDTH: 400; HEIGHT: 100"><%=sForm(3)%></textarea>
            </td>
      </tr>
      <tr>
            <td colspan="3" height="25" align="center">
                  <input type="submit" name="Button" value="Send">
            </td>
      </tr>
</table>
</form>
</body>
</html>
===========================================================================================================================
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now