View Full Version : Changing the 'TO' inbox field
SteveH
02-01-2008, 03:14 PM
Hello
I have a form behind which ASP declares, among others, the variable 'sEmailAddress', as in:
sEmailAddress = Request.Form("email")
This is the site visitor's email address and will appear to him, in the 'TO' part of his inbox, as angryTurtle@yahoo.com.
How can I change this so that, while still sending him a copy of his message, it appears like this:
To: angryTurtle
Thanks for any suggestions.
Steve
Spudhead
02-01-2008, 05:34 PM
aryEmailAddress = split(sEmailAddress, "@")
sUserName = aryEmailAddress(0)
SteveH
02-02-2008, 12:23 AM
Hello Spudhead
I never knew that existed. Wow!
OK, so something like this?
<%
Dim snameTitle,sname,sEmailTitle,sEmailAddress, aryEmailAddress, sUserName
snameTitle = "name"
sname = Request.Form("name")
sEmailTitle = "Email"
sEmailAddress = Request.Form("email")
aryEmailAddress = split(sEmailAddress, "@")
sUserName = aryEmailAddress(0)
Set myMail=CreateObject("CDO.Message")
myMail.Send
set myMail=nothing
%>
Cheers, great help.
Steve
SteveH
02-07-2008, 03:58 PM
Hello Spudhead
Sorry but I get an error message using this script:
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '[number: 0]'
/teddy/flashCota2.asp, line 56
This is the code I am using:
<%
Dim snameTitle,sname,sEmailTitle,sEmailAddress,aryEmailAddress,sbusinessTitle,sbusiness,sCountryTitle,sC ountryName,MessageName,MessageTitle
snameTitle = "name"
sname = Request.Form("name_txt")
sEmailTitle = "Email"
sEmailAddress = Request.Form("email_txt")
sbusinessTitle = "business"
sbusiness = Request.Form("business_txt")
sCountryTitle = "Country"
sCountryName = Request.Form("country_txt")
MessageName = "Message"
MessageTitle = Request.Form("message_txt")
aryEmailAddress = split(sEmailAddress, "@")
sname = aryEmailAddress(0)
Set myMail=CreateObject("CDO.Message")
Any suggestions would be appreciated.
Steve
Spudhead
02-07-2008, 04:55 PM
You need to check that your email address actually has a "@" in it:
if inStr(sEmailAddress,"@") > 1 then
aryEmailAddress = split(sEmailAddress, "@")
sname = aryEmailAddress(0)
else
'not a valid email
end if
SteveH
02-12-2008, 07:48 PM
Hello Spudhead
Thanks for your reply.
I haven't managed to try your script out yet, but is it doing this: it splits the name part of the email address (once it has verified the address contains an @) into the name part and then everything after the @?
So, if a site visitor sends a form with:
NAME: Peter Harris
EMAIL: tenPintPeter@whatever.com
the script will show the following in the inbox:
To: tenPintPeter
It will not show:
To: Peter Harris, will it (because that is what I would prefer)?
Cheers
Steve
SteveH
02-13-2008, 02:19 AM
Hello Spudhead
I get this error msg:
Subscript out of range: '[number: 0]'
Dim sname,sEmailAddress,sbusiness,sCountryName,MessageTitle,aryEmailAddress
myMail.To=sEmailAddress
aryEmailAddress = split(sEmailAddress, "@")
sname = aryEmailAddress(0)
if inStr(sEmailAddress,"@") > 1 then
aryEmailAddress = split(sEmailAddress, "@")
sname = aryEmailAddress(0)
else
'not a valid email
end if
If you could throw any light on the error msg I'd be grateful.
Steve
Whatever Jr.
02-13-2008, 09:29 AM
Try this,
Dim sname,sEmailAddress,sbusiness,sCountryName,MessageTitle,aryEmailAddress
if inStr(sEmailAddress,"@") > 1 then
aryEmailAddress = split(sEmailAddress, "@")
sname = aryEmailAddress(0)
myMail.To = sname
else
'not a valid email
end if
SteveH
02-13-2008, 02:22 PM
Hello Whatever Jr
Thnaks for your message.
Almost there! Your script does not generate any server errors, I receive the email in my inbox and I have the following in my inbox:
To: diamond0101@
That is, it shows the @
Cheers
Steve
Whatever Jr.
02-13-2008, 05:21 PM
What does sEmailAddress contain?
Tom
SteveH
02-13-2008, 10:45 PM
Hello Tom
sEmailAddress is the variable for the email address entered in the email address form field.
A copy of the message goes to the Webmaster, and another to sEmailAddress (the email of the site visitor).
Thanks.
Steve
Whatever Jr.
02-14-2008, 08:15 AM
What is the actual value contained in sEmailAddress?
Tom
SteveH
02-14-2008, 06:28 PM
Hello Tom
This is what I have:
sEmailAddress = Request.Form("email_txt")
The name 'email_txt' is the instance name of a field called email I have in an online Flash MX 2004 form.
Is that what you mean?
Steve
Whatever Jr.
02-15-2008, 02:35 PM
Nope,
what is the ACTUAL value contained in the var? Like 'foo@bar.com'?
Tom
SteveH
02-15-2008, 09:34 PM
Hello Tom
The actual value is whatever is input in the email field by the site visitor.
Steve
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.