Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

web form email without a mail client

Posted on 2004-04-21
4
Medium Priority
?
271 Views
Last Modified: 2009-02-11
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
Comment
Question by:nexcool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:pkaleda
ID: 10880681
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
 

Author Comment

by:nexcool
ID: 10881626
It would be windows 2000 server or 2003
0
 
LVL 6

Expert Comment

by:pkaleda
ID: 10881714
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
 
LVL 6

Accepted Solution

by:
Lord_McFly earned 1000 total points
ID: 10884815
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question