Solved

how to store the email address in a variable as written by the user in a textbox in ASP?

Posted on 2009-04-01
26
515 Views
Last Modified: 2012-05-06
i don't knew about ASP.Please help me out in this.
i have a variable in which i have statically stored the email address. i want to make it dynamic.

means when the user inputs the email id in the textbox , that email should be stored in a variable.

This all should be done in ASP. this is what i want.
0
Comment
Question by:designersx
  • 17
  • 8
26 Comments
 

Author Comment

by:designersx
ID: 24047187
please, i request u to give me the full code of this.

yogesh
0
 

Author Comment

by:designersx
ID: 24047268
to run asp in a browser i need to install IIS for which i need Windows XP CD but on the internet ,we can find the important files needed to install IIS on windows XP.

please give me quickly these files so that i can install IIS on my windows.

kind regads
yogesh

0
 

Author Comment

by:designersx
ID: 24048514
able to install IIS, no probs
0
 
LVL 15

Expert Comment

by:dosth
ID: 24053485
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form name="EmailForm" method="Post" action="test.asp">
Email: <input type="text" name="Email" size="50">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

assume that above is the page

you can get the user input like this

<%

Dim strEmail
strEmail = Request.form("Email")
Response.Write(strEmail)

%>
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24053523
designersx

A lot of wants and not enough information.

Can you better explain what it is that you are wanting to do?

Also.
To make sure that IIS is installed properly and that you can run .asp pages.
Open Notepad and add this into it

<%
response.write("Hello World, I have arrived")
%>

Save the file as       hello.asp
Making sure that the   File Type is set to [all]
Save it to your Web Directory, which is default:
C:\InetPub\wwwroot\

Now from your browser, type in.....
http://localhost/hello.asp

If you get a 500 error, that means that it is not working.
If you see           Hello World, I have arrived
Written to the page, then it is working, and we will go onto the next step.

=========
Next Step.
What are you wanting to do exactly.
Please be as specific as possible.
Let me know exactly what it is that you are wanting to accomplish.

Carrzkiss
0
 

Author Comment

by:designersx
ID: 24057596
i have installed IIS. when we send email , there are 4 things in that,
1) to
2) subject
3) from
4) body

from is the email id of visitor/ user who comes to our site.
so i want to make from variable dynamic.

in the below file [contactus.asp], please see    sEmail=Request.QueryString("Email")     this line of code

sFromEmail = "sEmail"   when i write sFromEmail ="admin@gmail.com" means static , it works but from variable is always dynamic while sending the form. and when i write sFromEmail = "sEmail" , error comes :- domain error 500. this email and other details are stored in database.
[contactus.htm]
 

<form method="post" name="contact_form" action="contactus.asp">

          <table border="0" cellpadding="0" cellspacing="0" width="99%">

            <tbody>

              <tr>

                <td colspan="2" align="left" valign="bottom"><table border="0" bordercolor="#3B5B80" cellpadding="0" cellspacing="0" width="100%">

                    <tbody>

                      <tr>

                        <td><table border="0" cellpadding="0" cellspacing="0" width="99%">

                          <body>

                              <td width="46%" height="35" align="left"><font face="Verdana" size="2"><font color="#000000" class="Utxt1"> Name</font><font color="#f74444" size="1" face="Verdana" class="Utxt4">*</font></font></td>

                              <td width="54%" align="left"><div align="left"> <font face="verdana,arial,helvetica"><small>

                                  <input name="Name" type="text" class="Utxt1" size="40">

                              </small></font> </div></td>

                          </tr>

                           <td align="left" height="35" valign="middle"><font face="Verdana" size="2"><font color="#000000" class="Utxt1"> 

                              E-mail</font><font color="#f74444" size="1" face="Verdana" class="Utxt4">*</font></font></td>

                            <td align="left" valign="middle"><div align="left"> <small><font face="verdana,arial,helvetica">

                                <input name="Email" type="text" class="Utxt1" size="40">

                            </font></small> </div></td>

                          </tr>

                          

                            <td align="left" height="35" valign="middle"><font color="#000000" size="2" face="Verdana" class="Utxt1">Phone</font></td>

                            <td align="left" valign="middle"><div align="left"> <small><font face="verdana,arial,helvetica">

                                <input name="Phone" type="text" class="Utxt1" size="40">

                            </font></small> </div></td>

                          </tr>

                          

                            <td align="left" height="35" valign="middle"><font face="Verdana" size="2"><font color="#000000" class="Utxt1">Branch</font><font color="#f74444" size="1" face="Verdana" class="Utxt4">*</font></font></td>

                            <td align="left" valign="middle"><font face="Verdana" size="1">

                              <select name="branch" size="1" class="Utxt1">

                                <option value="" selected="selected">-----</option>

                                <option value="1">Bayswater</option>

                                <option value="2">Chelsea Heights</option>

                                <option value="3">Clayton</option>

                                <option value="4">Fitzroy</option>

                                <option value="5">Footscray</option>

                                <option value="6">Frankston</option>

                                <option value="7">Geelong</option>

								<option value="8">Heatherton</option>

                                <option value="9">Port Melbourne</option>

								<option value="11">Thomastown</option>

                                <option value="10">Tullamarine</option>

                              </select>

                            </font></td>

                          </tr>

                          

                            <td align="left" height="35" valign="middle"><font color="#000000" size="2" face="Verdana" class="Utxt1">When do you need storage?</font></td>

                            <td align="left" valign="middle"><small><font face="verdana,arial,helvetica">

                              <input name="whenyns" type="text" class="Utxt1" size="40">

                            </font></small></td>

                          </tr>

                          

                            <td align="left" height="35" valign="middle"><font color="#000000" size="2" face="Verdana" class="Utxt1">Please describe what you have to store? <br>

                              (eg 3 bedroom house)</font></td>

                            <td align="left" valign="middle"><small><font face="verdana,arial,helvetica">

                              <input name="howmuch" type="text" class="Utxt1" size="40">

                            </font></small></td>

                          </tr>

                        </table></td>

                      </tr>

                    </tbody>

                </table></td>

              </tr>

              <tr>

                <td width="40%" height="35" align="left" valign="bottom"><font face="Verdana" size="2"><font color="#000000" class="Utxt2">Enquiry</font><font color="#f74444" size="1" face="Verdana" class="Utxt4">*</font></font><font color="#000000" face="Verdana" size="2">&nbsp; </font></td>

                <td align="left" valign="bottom" width="65%"></td>

              </tr>

              <tr>

                <td colspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%">

                    <tbody>

                      <tr>

                        <td height="138"><table border="0" cellpadding="0" cellspacing="0" width="100%">

                          <tbody>

                          <td width="98%" height="152" align="left" valign="top"><div align="left">

                                  <p><font face="verdana,arial,helvetica"><small>

                                  <textarea name="Enquiry" cols="100" rows="8" wrap="soft" class="Utxt1"></textarea>

                                  </small></font> </p>

                                <p> </p>

                              </div></td>

                          </tr>

                        </table></td>

                      </tr>

                </table></td>

              </tr>

              <tr>

                <td align="left" width="40%"></td>

                <td width="65%"><input name="Submit" type="submit" class="Utxt1" id="Submit" value="Submit"></td>

              </tr>

            </tbody>

          </table>

		  <input type="hidden" name="submitted" value="true">

        </form>
 
 

[contactus.asp]
 

<%

	Dim errMsgs

	errMsgs = ""

	OpenDataConnection

	

	IF GetParam("submitted") = "true" THEN

		sName = GetParam("Name")

		sEmail=Request.QueryString("Email")

		Response.Write( fname & )

		sPhone = GetParam("Phone")

		iBranchID = GetParam("branch")

		sWhenyns = GetParam("whenyns")

		sHowmuch = GetParam("howmuch")

		sEnquiry = GetParam("Enquiry")

		

		strEmailTemplate = Server.MapPath("secure\templates\email-contactus.html")

		

		ReadFile strEmailTemplate, sContent

		sContent = Replace(sContent, "{{name}}", TRIM(sName))

		sContent = Replace(sContent, "{{email}}", TRIM(sEmail))

		sContent = Replace(sContent, "{{phone}}", TRIM(sPhone))

		sContent = Replace(sContent, "{{branch}}", getBranchName(iBranchID))

		sContent = Replace(sContent, "{{whenyns}}", TRIM(swhenyns))

		sContent = Replace(sContent, "{{howmuch}}", TRIM(sHowmuch))

		sContent = Replace(sContent, "{{enquiry}}", TRIM(sEnquiry))

		sContent = Replace(sContent, "{{ipaddress}}", Request.ServerVariables("REMOTE_HOST"))

		

		sFromName = "Fry's Self Storage Admin"

		sFromEmail = "sEmail"

		sSubject = "Fry's Self Storage Enquiry"

		sTo = getBranchEmail(iBranchID)

	

		SendEmail sFromName, sFromEmail, sTo,"", sSubject, sContent

	ELSE

		Response.Redirect "contactus.html"		

	END IF

	CloseDataConnection

%>

Open in new window

0
 

Author Comment

by:designersx
ID: 24057621
hello dosth, u have done right but would u see the code here and what i am trying to do is giving me error.

sFromEmail = "sEmail"   error is here. mail concept is working the only thing is that from variable should not be static.   sEmail is the email when any user comes to our site and registers,  then his email should come in the from variable.

kind regards
yogesh
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 100 total points
ID: 24057648
Try this,
It is not a Querystring that you needed but a   .form

Carrzkiss
<%

	Dim errMsgs

	errMsgs = ""

	OpenDataConnection

	

	IF GetParam("submitted") = "true" THEN

		sName = GetParam("Name")

		sEmail=Request.Form("Email")

		Response.Write("fname")

		sPhone = GetParam("Phone")

		iBranchID = GetParam("branch")

		sWhenyns = GetParam("whenyns")

		sHowmuch = GetParam("howmuch")

		sEnquiry = GetParam("Enquiry")

		

		strEmailTemplate = Server.MapPath("secure\templates\email-contactus.html")

		

		ReadFile strEmailTemplate, sContent

		sContent = Replace(sContent, "{{name}}", TRIM(sName))

		sContent = Replace(sContent, "{{email}}", TRIM(sEmail))

		sContent = Replace(sContent, "{{phone}}", TRIM(sPhone))

		sContent = Replace(sContent, "{{branch}}", getBranchName(iBranchID))

		sContent = Replace(sContent, "{{whenyns}}", TRIM(swhenyns))

		sContent = Replace(sContent, "{{howmuch}}", TRIM(sHowmuch))

		sContent = Replace(sContent, "{{enquiry}}", TRIM(sEnquiry))

		sContent = Replace(sContent, "{{ipaddress}}", Request.ServerVariables("REMOTE_HOST"))

		

		sFromName = "Fry's Self Storage Admin"

		sFromEmail = "sEmail"

		sSubject = "Fry's Self Storage Enquiry"

		sTo = getBranchEmail(iBranchID)

	

		SendEmail sFromName, sFromEmail, sTo,"", sSubject, sContent

	ELSE

		Response.Redirect "contactus.html"		

	END IF

	CloseDataConnection

%>

Open in new window

0
 

Author Comment

by:designersx
ID: 24057768
i  am getting this error

sFromEmail

Persits.MailSender.4 error '800a0006'

501 Your domain does not seem to be valid. Could not find MX record for your domain.

/common.asp, line 286
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24057802
Make sure that you type out the email address correctly and in the correct format

you@domain.com
0
 

Author Comment

by:designersx
ID: 24057852
this error is coming

      
Microsoft VBScript compilation  error '800a03ea'

Syntax error

/contactus.asp, line 10

Response.Write( fname & )
------------------------^
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24057879
did you use the code that I supplied?
Please look at it, and copy what I have in the code.
You will see what some of the things are changed.

Please look at my code...

Carrzkiss
0
 

Author Comment

by:designersx
ID: 24057923
i have tried ur complete sir,

this error is there.

fname

Persits.MailSender.4 error '800a0006'

501 Your domain does not seem to be valid. Could not find MX record for your domain.

/common.asp, line 286
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:designersx
ID: 24057926
should i give u common.asp file?
0
 

Author Comment

by:designersx
ID: 24057941
complete code sir

kind regards,
yogi
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24057946
I will be unable to test it as I do not have the same mail component as you do.

Do this please

Response.Write( fname & )
change to
Response.Write("fname")

Let me know what happens?
0
 

Author Comment

by:designersx
ID: 24057947
i mean to say sorry i misspelled above, i used Ur complete code sir.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24057957
never mind and what I sayed to change...
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24058022
when you run the code with everything the way you had it, EXCEPT but this
sEmail=Request.QueryString("Email")
Changed to
sEmail=Request.Form("Email")

What do you get? What happens?
0
 

Author Comment

by:designersx
ID: 24058023
i changed and after changing this error is coming,

fname
Persits.MailSender.4 error '800a0006'
501 Your domain does not seem to be valid. Could not find MX record for your domain.
/common.asp, line 286
0
 

Author Comment

by:designersx
ID: 24058044
ok sorry i have not checked and told u the result, just hold on i am checking sir. sorry for that
0
 

Author Comment

by:designersx
ID: 24058086
now see ,

when i only wrtie form instead of query string then, this error comes

Microsoft VBScript compilation  error '800a03ea'
Syntax error
/contactus.asp, line 10
Response.Write( fname & )
------------------------^

and when i write form and do "fname" instead of fname &

this error comes
fname
Persits.MailSender.4 error '800a0006'
501 Your domain does not seem to be valid. Could not find MX record for your domain.
/common.asp, line 286

this is the status before reading reading ur latest comment.

let me read ur last comment and then i let u know .

ok sir.
0
 

Author Comment

by:designersx
ID: 24058235
i am sending u common.asp file and contactus.asp file.

convert the extension from .txt to .asp files , it was to upload these files.

yogesh
common.txt
contactus.txt
0
 

Author Comment

by:designersx
ID: 24059251
i have made a simple program, but there is error coming at the same point when i have uploaded that on the server. check ou the link,

http://designers-x.com/projects/projects/send_mail_asp/2/test.asp

why there is a error at this line, myMail.Send

error is: -

CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
/projects/projects/send_mail_asp/2/test.asp, line 7
[test.asp]
 

<%

Set myMail=CreateObject("CDO.Message")

myMail.Subject="Sending email with CDO"

myMail.From="mymail@mydomain.com"

myMail.To="yogeshban@gmail.com"

myMail.TextBody="This is a message."

myMail.Send

set myMail=nothing

%>

Open in new window

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24062859
Also, I see that you have changed in your mail component from what you had before.
This error is caused of several reasons:
You cannot relay mail through your mail server (Which is most likely the issue)
As I see here in you      myMail.To="yogeshban@gmail.com"
Meaning that you are sending to someone.

If you want help with this, then that is another issue.
You have several different things going on here.
So.

Open up a new post for this issue.
And either myself or someone else will assist you with the mail issue.

----------
We need to get the mail issue fixed, in order to fix this post's issue.

So, lets get this all wrapped up here OK?

0
 

Author Comment

by:designersx
ID: 24065903
yes sir, i have asked a new question for mail issue with asp?

problems are coming with SMtp server   or  transportation failure  like this.

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now