Click to See Complete Forum and Search --> : what have i done wrong...
benbramz
06-12-2005, 09:07 PM
hi
what have i done wrong here? ive tried several ways and its how ive done the "" part. but how should it be done
myMail.From="administrator@site.com"
myMail.To="request.form("to")"
myMail.Subject="request.form("subject")"
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body=HTML
myMail.Send
set mymail=nothing
Response.Write "Message Sent!"
%>
this is all of the code just so there is some context to what im asking
<%
Dim myMail
Dim HTML
Set myMail = CreateObject("CDONTS.NewMail")
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "The administrator Has sent you an email:<br><br>"& request.form("message") &""
HTML = HTML & "</body>"
HTML = HTML & "</html>"
myMail.From="administrator@site.com"
myMail.To="request.form("to")"
myMail.Subject="request.form("subject")"
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body=HTML
myMail.Send
set mymail=nothing
Response.Write "Message Sent!"
%>
cheers!
buntine
06-12-2005, 09:28 PM
What is actually happening? Are you getting an error? Or are your receiving "Message Sent!" but no email?
Regards.
benbramz
06-12-2005, 09:37 PM
yea i get it and i get no email.
i changed this bit
myMail.To="request.form("to")"
to
myMail.To="myemailaddy@hotmail.com"
and it worked.
cheers
benbramz
06-12-2005, 09:47 PM
meant to add this on the end! forgot
so how do i write that line to work?
buntine
06-12-2005, 11:05 PM
You are enclosing the variable in quotes, so it is treated as a string literal. It needs to look like this:
myMail.To = Request.Form("to")
Regards.
benbramz
06-13-2005, 12:55 PM
hi
its still didnt work?
i wondered though if it was the email server that was slow so i decided to place my email addy in instead. i got the email but the subject was (no subject) and i DID put somthing in the suject field.
im stumpped even more :confused: all help appriciated
thanks
you have the same quotes thing with the subject. fix those and post your updated code.
benbramz
06-13-2005, 03:22 PM
here
myMail.From="administrator@rocklegacy.com"
myMail.To = request.form("mailto")
myMail.Subject=request.form("subject")
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body=HTML
myMail.Send
set mymail=nothing
Response.Write "Message Sent!"
%>
the to section doesnt work but now but the subject does as id named the form somthing differnt. but ive checked the to field. its a drop down box that has a list of emails from a db on it. would it make any differnce?
are you providing the correct value in this drop down field on your form. post the code for that form.
benbramz
06-14-2005, 04:54 PM
ok
heres the form page
by the way ive covered up info i dont want public like my db address and email so i dont get picked up by spam bots (*****)
thankyou
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<a href="default.asp">Home</a> | <a href="login.asp">Back</a> <br>
<form name="form1" method="post" action="admincontactconn.asp">
<div align="left"></div>
<table width="2%" border="0" align="center" cellpadding="0" id="table1">
<tr>
<td>To :</td>
<td>
<%
Dim objConn, objRst
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.MapPath("*****\*****.mdb"))
Set objRst = Server.CreateObject("ADODB.Recordset")
objRst.Open "profile", objConn, 2, 2, 2
'
If Not objRst.EOF Then
%>
<FONT FACE="sans-serif"><SELECT id="mailto" NAME="mailto">
<%
Do While Not objRst.EOF
%>
<option value="<%=objRst.Fields("username")%>"><%=objRst.Fields("username")%> - <%=objRst.Fields("email")%></option>
<%
objRst.MoveNext
Loop
%>
</SELECT>
</FONT>
<%
Else
Response.Write "<p>No data found.</p>"
End If
'
objRst.Close
Set objRst = Nothing
objConn.Close
Set objConn = Nothing
%>
(listed in usernames)
</td>
</tr>
<tr>
<td>Subject : </td>
<td>
<input name="subject" type="text" id="subject" size="75"></td>
</tr>
<tr>
<td>Message:</td>
<td>
<textarea name="message" cols="71" rows="7" id="message"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Send Email"></td>
</tr>
</table>
<br>
</form>
</body>
</html>
and this is the page in question
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<%
Dim myMail
Dim HTML
Set myMail = CreateObject("CDONTS.NewMail")
HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>User has emailed you</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "The administrator Has sent you an email:<br><br>"& request.form("message") &""
HTML = HTML & "</body>"
HTML = HTML & "</html>"
myMail.From="administrator@*****.com"
myMail.To=request.form("mailto")
myMail.Subject=request.form("subject")
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body=HTML
myMail.Send
set mymail=nothing
Response.Write "Message Sent!"
%>
<link href="main.css" rel="stylesheet" type="text/css">
<br><a href="login.asp">Click here to go back </a>
</HEAD>
<BODY>
</BODY>
</HTML>
buntine
06-14-2005, 05:43 PM
The form item "mailto" is returning the users Username rather then his/her email address. When using a combo box, the browser passes whatever has been put in the "value" attribute of the <option> element to the server. You have put the users Username in there.
It should look like this:
<FONT FACE="sans-serif"><SELECT id="mailto" NAME="mailto">
<%
Do While Not objRst.EOF
%>
<option value="<%=objRst.Fields("email")%>"><%=objRst.Fields("username")%> - <%=objRst.Fields("email")%></option>
<%
objRst.MoveNext
Loop
%>
</SELECT>
It should work now.
Regards.
benbramz
06-14-2005, 06:43 PM
thankyou buntine and wmif for your help! :D
cant belive i missed somthing so simple out. but experience comes from messing up so i suppose i have a long journey! lol
again, thanks
buntine
06-14-2005, 07:02 PM
No worries. ;) Like they say; its not about the journey, its about the destination!
buntine beat me to it. :) glad its working now.