PDA

View Full Version : CDONTS: Send mail to address from field


mattboy_slim
01-07-2003, 10:44 PM
How can I send an email to someone who has just filled out a form? They enter their email address into the form, but I'm not sure what I need to specify in the "CC" field of the CDONTS code to send the mail.

You can see, that right now I have specified: &request.form(Email) which does not work.

Here is the page:
http://www.lakesnewsshopper.com/submit.asp

Here is the code:

<%
if Request.Form("FFSubmitted") = "yes" then
Dim BodyString
Dim ExcludeFields
Dim objCDO
Dim RedirectURL
Set objCDO = Server.CreateObject("CDONTS.NewMail")
ExcludeFields = "addOver" & "wordsOver" & "amount" & "words" & "submit" & "FFSubmitted"
objCDO.From = "REQUEST: Classified"
objCDO.To = "***@***"
objCDO.Cc = "&request.form(Email)"
objCDO.Bcc = ""
objCDO.Subject = "Classified Ad Request"
BodyString = "Thank you for submitting your ad to Lakes News Shopper." & chr(13) &_
" " & chr(13) &_
"Please review the below information to ensure everything is correct." & chr(13) &_
"If any information below is incorrect, please send an email immediately to: sales@lakesnewsshopper.com" & chr(13) &_
" " & chr(13) &_
"Your Cost: "&request.form("Amount") & chr(13) &_
" " & chr(13) &_
"Name: "&request.form("Name") & chr(13) &_
"Email: "&request.Form("Email") & chr(13) &_
"Address: "&request.form("Address") & chr(13) &_
"City: "&request.form("City") & ", "&request.form("State") & " "&request.form("Zip") & chr(13) &_
"Phone: "&request.form("Phone") & chr(13) &_
"Weeks To Run Ad: "&request.form("Weeks_To_Run") & chr(13) &_
"Date To Start Ad: "&request.form("Date_To_Start") & chr(13) &_
"Ad Wording: "&request.form("Ad_Wording")
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 0
objCDO.Send
Set objCDO = Nothing
RedirectURL = "thanks.asp"
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if
end if
%>


Thanks in advance for the help. This place has been great so far.

Matt

whammy
01-08-2003, 01:59 AM
You have that a bit sideways... the "To" field is what you need...


objCDO.To = "***@***"
objCDO.Cc = "&request.form(Email)"


Is wrong... the "To" field is where the email gets sent. It should be:

objCDO.To = Request.Form("Email") ' Note the quotes, you left them out on accident
objCDO.Cc = "" ' this does not need a value...


Also, CDONTS will not always work unless you specify a valid "From" email address, i.e.:

"webmaster@yourwebsite.com"

I usually use one that is on the server, but you can use:

"REQUEST: Classified" <webmaster@yoursite.com>

replacing <webmaster@yoursite.com> with a valid email address.

:)

mattboy_slim
01-08-2003, 05:16 AM
Actually, the ****@**** is me, and the CC field is supposed to go to the user filling out the form. Rather than make 2 separate emails, I'm just sending myself the same one they receive.

Otherwise, it works fine. The form works great as is. I read that you need to specify a real email address in another post on this forum, but my email server apparently is not picky.

Thanks for the help again with this problem Whammy. Didn't even know I needed quotes there. I'll test it tomorrow when I get to work and let you know how it goes.

mattboy_slim
01-09-2003, 02:39 PM
It doesn't seem to work. I put an email address in the form, but it won't send to the address. It does send fine to my address though.

What are some troubleshooting steps I can try?

EDIT:

So far this morning, I have tried to put quotation marks around the Request.Form("Email") and have tried to put quotation marks around the email when entering it into the text field.

arnyinc
01-09-2003, 04:11 PM
Make sure the cc line read:

objCDO.Cc = request.form("Email")

If that doesn't work, make sure you are getting the correct value for your email field. Just try something simple like:

response.write request.form("Email")

and make sure it isn't blank.

mattboy_slim
01-09-2003, 05:34 PM
I'm getting a correctly formatted email address and all that. It even reports back fine in the body of the email.

whammy
01-11-2003, 01:08 AM
Have you tried a valid "from" address?

i.e. an email address that is registered on the same server? I have found that CDONTS (sometimes, but not always, which is confusing) fails without that, and it's not very predictable, that's something I need to learn, too, but it DEFINITELY works with a valid email address hosted on the server.

mattboy_slim
01-13-2003, 02:32 PM
Yeah, I have it running like that right now for testing purposes. Both the "TO" and "CC" addresses are hosted on the local Exchange server.

mattboy_slim
02-03-2003, 04:11 PM
I just got back to this web site again. This is still an issue.

Anyone have any new ideas?

http://www.lakesnewsshopper.com/submit.asp


<%
if Request.Form("FFSubmitted") = "yes" then
Dim BodyString
Dim ExcludeFields
Dim objCDO
Dim RedirectURL
Set objCDO = Server.CreateObject("CDONTS.NewMail")
ExcludeFields = "addOver" & "wordsOver" & "amount" & "words" & "submit" & "FFSubmitted"
objCDO.From = "REQUEST: Classified"
objCDO.To = "hidden@hidden.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "Classified Ad Request"
BodyString = "Thank you for submitting your ad to Lakes News Shopper." & chr(13) &_
" " & chr(13) &_
"Please review the below information to ensure everything is correct." & chr(13) &_
"If any information below is incorrect, please send an email immediately to: sales@lakesnewsshopper.com" & chr(13) &_
" " & chr(13) &_
"Your Cost: "&request.form("Amount") & chr(13) &_
" " & chr(13) &_
"Name: "&request.form("Name") & chr(13) &_
"Email: "&request.Form("Email") & chr(13) &_
"Address: "&request.form("Address") & chr(13) &_
"City: "&request.form("City") & ", "&request.form("State") & " "&request.form("Zip") & chr(13) &_
"Phone: "&request.form("Phone") & chr(13) &_
"Weeks To Run Ad: "&request.form("Weeks_To_Run") & chr(13) &_
"Date To Start Ad: "&request.form("Date_To_Start") & chr(13) &_
"Ad Wording: "&request.form("Ad_Wording")
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 0
objCDO.Send
Set objCDO = Nothing
RedirectURL = "thanks.asp"
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if
end if
%>

arnyinc
02-03-2003, 05:28 PM
You left the relevant line of code blank. objCDO.Cc="" will not cc it to anyone.


'this is what you started with
objCDO.Cc = "&request.form(Email)"

'this is what you currently have
objCDO.Cc = ""

'this is what you need to have
objCDO.Cc = request.form(Email)


I would also remove the .bcc line if you are not using it.

mattboy_slim
02-03-2003, 05:38 PM
Yeah, I left it blank because nothing I try works.

Tried your code, I can't get that to work either.

If I leave it without the quotations marks around the piece, then I get a script error, and the page will not submit.

If I put quotation marks around it, then the client who put their email address in the field never gets the email. I get the email, but the person who filled out the form does not.

arnyinc
02-03-2003, 05:47 PM
Sorry, I grabbed the wrong piece of code. Try:


'note the quotation marks around email
objCDO.Cc = Request.Form("Email")


I don't think the bcc field will cause any problems, but I would comment it out just in case.

Post any script errors, if this code produces any.

mattboy_slim
02-03-2003, 05:49 PM
Got it, thanks.

May I say again, this place rocks.