View Full Version : asp mail form
padone
05-31-2005, 04:25 PM
Does anyone now of a simple tutorial that i will be able to follow that shows me how to post a form to asp with these fields on
your name - puts your name in the email
your email - emails you a notification
Their name - name it goes to
their mail - email address it goes to
I am quite slow and sometimes cant understand tutorials so please be easy on me
padone
05-31-2005, 04:41 PM
on my flash page i have a form with this in the first keyframe
submit.onPress = function(){
if(yourname.text!="" && yourtime.text !="" && youremail.text!=""){
myData.yourname = yourname.text
myData.yourtime = yourtime.text
myData.youremail = youremail.text
myData.sendAndLoad("mail.asp", myData, "POST")
}
}
myData = new LoadVars()
myData.onLoad = function(){
if(this.writing=="Ok") {
gotoAndPlay(8)
status.text = "Submited data was saved"
}
else status.text = "Error in saving submitted data"
}
stop();
and in my asp i have
<%
strHost = "mail.streamingradio.co.uk"
If Request("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = strHost
Mail.From = Request("youremail")
Mail.FromName = Request("yourname")
Mail.AddAddress Request("theiremail")
Mail.Subject = "GT Karting Challenge"
Mail.Body = Request("message")
strErr = ""
bSuccess = False
On Error Resume Next
Mail.Send
If Err <> 0 Then
strErr = Err.Description
else
bSuccess = True
End If
End If
Response.write("&writing=Ok")
cn.Close
%>
you can view it here to see it NOT working
http://www.gameman.co.uk/karting.html
:eek:
mmm..pi..3.14..
05-31-2005, 05:26 PM
Is your asp page in VB or C# format??
almost forgot to add, to receive GET variables from flash, use Request.Form("variableName"), not just Request("variableName") ;)
Eric
padone
06-01-2005, 09:32 AM
I have the form now posting to the asp but it actually doesn't send an email.
Have i missed anything from the asp or flash
submit.onPress = function(){
if(yourname.text!="" && youremail.text !="" && theirname.text!="" && theiremail.text!="" && tmessage.text!=""){
form.yourname = yourname.text
form.youremail = youremail.text
form.theirname = theirname.text
form.tmessage = tmessage.text
form.theiremail = theiremail.text
form.sendAndLoad("mail.asp", form, "POST")
}
}
form = new LoadVars()
form.onLoad = function(){
if(this.writing=="Ok") {
gotoAndPlay(26)
status.text = "Challenge Sent"
}
else status.text = "Error Sending Challenge"
}
stop();
<%
strHost = "mail.t2euk.com"
If Request("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = strHost
Mail.From = Request.Form("youremail")
Mail.FromName = Request.Form("yourname")
Mail.AddAddress Request.Form("theiremail")
Mail.Subject = "GT Karting Challenge"
Mail.Body = Request("tmessage")
strErr = ""
bSuccess = False
On Error Resume Next
Mail.Send
If Err <> 0 Then
strErr = Err.Description
else
bSuccess = True
End If
End If
Response.Write "&writing=Ok"
%>
you can view it here if you play the game then press challenge a friend and go through the forms its the email one.
http://www.gameman.co.uk/karting.html
Your problem may not be your code. Make sure your server supports that Mail object. Many ASP servers are using CDONTS mail objects as of late. Just something else to look at.
padone
06-01-2005, 11:26 AM
what type am i using here?
what are the different types?
I suppose i should have checked that out first
:eek:
Set Mail = Server.CreateObject("Persits.MailSender")
This is your mail object(Persits.MailSender). Check with the host to see if its supported, and if now, which mail object is supported.
Here are some links to ASP mailer tutorials with different objects
http://www.spoono.com/asp/tutorials/tutorial.php?id=18
http://mavweb.net/aspmail-faqs.asp
padone
06-01-2005, 11:39 AM
I have downloaded another asp page
<%
FirstName = Request.form("FirstName")
Email = Request.form("Email")
Company = Request.form("Company")
ToComments = Request.form("ToComments")
HearAbout = Request.form("HearAbout")
strName = Request.form("ToName")
strEmail = Request.form("ToEmail")
strSubject = "GT Karting Challenge"
strBody = ToComments & HearAbout & Company
Set Mailer = Server.CreateObject("Persits.MailSender")
Mailer.RemoteHost = "mail.streamingradio.co.uk"
Mailer.FromName = FirstName
Mailer.FromAddress = Email
Mailer.AddRecipient strName, strEmail
Mailer.Subject = (strSubject)
Mailer.BodyText = strBody
if Mailer.SendMail then
Response.Write "EmailStatus=Complete - Your mail has been sent"
else
Response.Write "EmailStatus=Failure - Your mail was not sent - errors"
Response.Write Mailer.Response
end if
%>
I far as I can see this should work but doesnt???
WoW, you're using Post, Request.Form should just be Request..totally spaced on that one..
padone
06-06-2005, 11:04 AM
Cheers but I got it sorted now I have one little problem though in my asp file i have it sending to a email that the user puts into flash now in my asp I have
Mail.Body = "You have been challenged to beat this score at http://www.mydomain.co.uk"
But i need to add in some variable names into the middle of that so it reads
You have been challenge by "yourname" to beat there score of "totalrace" at http://www.mydomain.co.uk
when I just simple add it in nothing comes through on the email
Any ideas??
Mail.Body = "You have been challenged by " & VariableForName & " to beat this score of " & VariableForScore & " at http://www.mydomain.co.uk"
Did you try that?
padone
06-09-2005, 09:19 AM
That worked a treat
padone
06-13-2005, 04:58 PM
Hey
I need to load a asp file into my flash site to display some highscore results
I have this on my flash page
2 dynamic text fields and a button
yourname = 1st text field
yourtime = 2nd text field
and on my button i got
on (release) {
loadVariablesNum("load.asp", 0);
}
and in my asp page i have
<%
Option Explicit
Dim cn
Dim cmd
Dim rs
Dim cont
Set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "scorescrashnet"
cn.Open
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
cmd.CommandText = "SELECT yourname, yourtime, youremail FROM crashscores"
Set rs = cmd.Execute
cont=0
Do Until rs.EOF
Response.Write "yourname"&cont&"="& rs("yourname") & "&" &"yourtime"&cont&"="& rs("yourtime") &"&" &"youremail"&cont&"="& rs("youremail")& "&"
cont = cont+1
rs.MoveNext
Loop
Response.Write "&cant="&cont
rs.Close
cn.Close
%>
Which version of flash are you using?
padone
06-13-2005, 05:29 PM
mx pro
Since you're using MX Pro, use LoadVars() instead of LoadVariablesNum. It will give you more control over sending and loading variables..
Hello people..
Day 3 of trying to get my ASP/CDO/CDONTS to send out a friggin mail... still no joy. Would SOMEONE please post something that works...? Why cant it be easy, like PHP. :(
If I run just a sample page (posted by Cota) all on its own with no dynamic data, it send the mail. AS soon as I try and hook it up to Flash - kaboom. No mail sent...
Please oh please help...
Fanks! Bye! :D
Post the code that your currently working with..
Righto.. I have tried using CDO as I wasnt having any luck with CDONTS...
here the ASP
<%
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mySmtp"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
dim sender,mailaddy,usermessage
sender = Request.Form("name")
mailaddy = Request.Form("email")
usermessage = Request.Form("message")
With cdoMessage
Set .Configuration = cdoConfig
.From = sender
.To = "me@mine.co.za"
.Subject = "Mail"
.TextBody = usermessage
.Send
End With
if Err then
Response.Write "&faultCode=1"
else
Response.Write "&faultCode=0"
end if
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
and here the Flash (8) Cota, this should look familiar ;)
_lv = new LoadVars();
_lv.onLoad = function() {
if (this.faultCode == 0) {
response_txt.text = "Thanks -- your message has been sent.";
} else {
response_txt.text = "There was a problem sending your message.";
}
};
send_bmc.onRelease = function() {
response_txt.text = "";
var ok = true;
if (message_txt.text == '' || message_txt.text == 'Your Message') {
response_txt.text = "You haven't typed in a message";
ok = false;
} else {
_lv.message = message_txt.text;
}
if (number_txt.text == '' || number_txt.text == 'Your Phone Number') {
response_txt.text = "Please enter your phone number";
ok = false;
} else {
_lv.number = number_txt.text;
}
if (email_txt.text == '' || email_txt.text.indexOf('@') == -1) {
response_txt.text = "Please enter your email address";
ok = false;
} else {
_lv.email = email_txt.text;
}
if (name_txt.text == '' || name_txt.text == 'Your Name') {
response_txt.text = "Please enter your name";
ok = false;
} else {
_lv.name = name_txt.text;
}
if (ok) {
response_txt.text = "Sending...";
// I have tried both methods. The getURL returns very weird variables in the adress bar... :S
//_lv.sendAndLoad("sendemail.asp", _lv, "POST");
//getURL ("sendemail.asp", "_blank" , "GET")
}
};
Selection.setFocus("name_txt");
Fanks... much obliged!
I'm not a big fan of CDO, but I think one issue is the SMTP. You have to set it to your specific SMTP on that server.
Hey Cota.
Thanks for taking time.
Heres what I did:
My server only supports PHP (Lets call it "myServer"). So, I uploaded to a server that supports CDONTS and CDO ("theirServer"). I used myServer's SMTP details on theirServer. Could that be why it wouldnt send?
Definetly...it wont sent because its a 3rd party SMTP at that point..they're blocking the hell out of it.
Shot matey! :D
I shall have to get in contact with the client and organise some server space for me to test on then.
Cheers,
THanks for clearing it up!
spillml
05-03-2006, 08:16 PM
Hello all,
I am new to this forum, and have not had a ton of programming experience. I have caught on pretty fast to everything that I have learned up to this point in Flash and in scripting asp.
I am having the same sort of problem with sending an email from Flash via an .asp. I am able to send an email, but the variables that I am trying to send from flash to the .asp always return as undefined in the email. I have been working on this for a while now and really would appreciate the help. Attached is the code for flash and the code for the .asp. I am using Flash MX 2004.
My .asp code is as follows:
<%@language="VBSCRIPT"%>
<%
UserName = Request("fname")
Email = Request("email")
Novel = Request("novel")
strName = Request("fname")
strBody = "You have received confirmation of completion from:" & Username & Email & Novel
server.ScriptTimeout = 300
Set objMail = CreateObject("CDONTS.NewMail")
objMail.From = Email
objMail.To = "my email address"
objMail.Subject = "Test Email"
objMail.Body = strBody
objMail.Send
set objMail = Nothing
Server.ScriptTimeout = 90
%>
My flash code is as follows:
stop();
function sendForm (){
form = new LoadVars();
form.fname=_parent.name_txt.text;
form.email=_parent.email_txt.text;
form.novel=_parent.novel_txt.text;
form.send ("send2.asp", "POST");
};
send_btn.onRelease = function (){
if (name_txt.text == "" || email_txt.text == "" || novel_txt.text == ""){
status_txt.text = "Please complete the entire form...";
}
else {
status_txt == "";
sendForm();
nextFrame;
}
};
I really appreciate any help that I can get.
Might be a scope issue with the textbox paths in the function. Try replacing them with an absolute path starting from the _root and see if you still have the same issue.
spillml
05-04-2006, 01:49 PM
Thanks COTA, That worked like a dream.
spillml
05-04-2006, 01:54 PM
For those of you that might be having the same problem, I will post my final script:
ASP CODE
<%@language="VBSCRIPT"%>
<%
UserName = Request("fname")
Email = Request("email")
Novel = Request("novel")
strName = Request("fname")
strBody = "You have received confirmation of completion from:" & Username & vbCRLF "Email Address" & Email & vbCRLF & "Novel ID:" & Novel
server.ScriptTimeout = 300
Set objMail = CreateObject("CDONTS.NewMail")
objMail.From = Email
objMail.To = "my email address"
objMail.Subject = "Test Email"
objMail.Body = strBody
objMail.Send
set objMail = Nothing
Server.ScriptTimeout = 90
%>
Flash Code:
stop();
function sendForm (){
form = new LoadVars();
form.fname= name_txt.text;
form.email= email_txt.text;
form.novel= novel_txt.text;
form.send ("Send2.asp", "POST");
};
send_btn.onRelease = function (){
if (name_txt.text == "" || email_txt.text == "" || novel_txt.text == ""){
status_txt.text = "Please complete the entire form...";
}
else {
status_txt == "";
sendForm();
nextFrame;
}
};
Appreciate you posting the final code for others to see.
t-bonist
05-18-2006, 05:22 AM
Hi Spillml,
I've tried the codes u provided. i presumed i did the setup correctly..
But i got this error when i click the send button.
---------------------------------------------------------------------
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/test/Send2.asp, line 10
strBody = "You have received confirmation of completion from:" & Username & vbCRLF "Email Address" & Email & vbCRLF & "Novel ID:" & Novel
-----------------------------------------------------------------------------------^
---------------------------------------------------------------------
Help, anyone?
You're missing "&"
strBody = "You have received confirmation of completion from:" & Username & vbCRLF "Email Address" & Email & vbCRLF & "Novel ID:" & Novel
should be
strBody = "You have received confirmation of completion from:" & Username & vbCRLF & "Email Address" & Email & vbCRLF & "Novel ID:" & Novel
t-bonist
05-18-2006, 06:04 AM
Hi Cota,
That pretty much carried me to the next level~ :)
But now i'm faced with another problem...
----------------------------------------------------------------
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object: 'CDONTS.NewMail'
/test/Send2.asp, line 13
----------------------------------------------------------------
Sounds like some major problem to me.. Pls pardon me coz i'm still trying to pick up actionscript.
Bob
Well it isnt a big problem, just one you cant overcome. It cant create a CDONTs object most likely because your server doesnt support it. Double check with your host to make sure they support CDONTs...
t-bonist
05-18-2006, 07:09 AM
Ouch~~~!
Alritey, i tink i cant possibly swoop the servers with my current resources. :P
I'll try to work around this prob. :)
Thanks a million Cota!
Cheers
Bob
You can look into CDOSY..that is most likely supported by your server..just swap all the CDONTs stuff for the CDOSY and you'll be fine.
trane65
05-18-2006, 09:41 PM
Having sort of the same issues with Flash and ASP integration and no luck with other forums/tutorials etc.
I'm creating an email form in Flash that communicates (or is supposed to) with an ASP form on a GoDaddy server with CDONTS enabled. I'm new at this and can't get it working properly.
The form is set up correctly with 'name', 'email', and 'message' fields all named instances. There is also a submit button with the following actionscript:
on (release) {
getURL("message.asp", "", "POST");
}
Then the actual message.asp file which is coded as such:
<% @language="VBSCRIPT" %>
<%
Dim myMail, myBody
myBody = "Name: "& request.form("name") & vbcrlf
myBody = myBody & "Email: "& request.form("email") & vbcrlf
myBody = myBody & "Message: "& vbcrlf & request.form("message")
Set myMail = CreateObject("CDONTS.NewMail")
myMail.BodyFormat=1
myMail.MailFormat=1
myMail.From=request.form("email")
myMail.To=("travismandrell@hotmail.com")
myMail.Subject="Flash MX Basic Email"
myMail.Body=myBody
myMail.Send
set myMail=nothing
%>
<html>
<title>mail</title>
<head>
<!--THIS BIT SENDS VISITOR BACK TO basic_mail.htm AFTER 3 SECONDS-->
<meta http-equiv="refresh" content="3;URL=home.html">
</head>
<!--THIS BIT SAYS THANKS AND HAS A MANUAL LINK BACK TO basic_mail.htm-->
<body bgcolor="#FFFFFF" text="#000066" link="#0000CC" vlink="#0000CC" alink="#0000CC">
<div align="center">
<p><font face="Verdana" size="2" color="#000080"> <font face="Arial, Helvetica, sans-serif" size="4"><b>Thank you. Your message has been sent.</b></font></font></p>
<p><b><font face="Arial, Helvetica, sans-serif" size="4" color="#000080">To
Return To SHAPCO Productions</font></b></p>
<p><b><font face="Arial, Helvetica, sans-serif" size="4" color="#000080"><a href="home.html">Click
Here</a> </font></b> </p>
</div>
</body>
</html>
I've uploaded the publilshed .swf and .asp to the server via the ftp client. Both the html where the swf is embedded and the .asp file are in the root directory. The form appears to work as the HTML page loads after clicking 'submit' but no email is ever recieved.
Anyone have any ideas? Perhaps the location of a better tutorial on how to do this?
Thanks in advance
Much like you would use trace() in flash, use Response.write in ASP to display the variables coming in from Flash..make sure the variables are being sent to ASP correctly..
t-bonist
05-19-2006, 04:42 AM
Hi Cota, i've used CDO to resolve the mailing problem, but thanks for your advice nevertheless. :)
Now i'm faced with another issue. When i click the send button on my fla, the Send2.asp file is called and it pops out as a new window on my desktop. The problem is, is there anything i can do to prevent the Send2.asp file from popping out?
:confused:
Yes...how are you calling the ASP file, and whats in it?
t-bonist
05-19-2006, 05:11 AM
Basically I'm using the same codes that Spillml shared. The Send2.asp is the file that the .fla sends the data to, where in turn, Send2.asp will send out the email to my mailbox.
stop();
function sendForm (){
form = new LoadVars();
form.fname= name_txt.text;
form.email= email_txt.text;
form.novel= novel_txt.text;
form.send ("Send2.asp", "POST");
};
send_btn.onRelease = function (){
if (name_txt.text == "" || email_txt.text == "" || novel_txt.text == ""){
status_txt.text = "Please complete the entire form...";
}
else {
status_txt == "";
sendForm();
nextFrame();
}
};
Any help is much appreciated :)
maybe form.send ("Send2.asp"); sometimes things can get screwie..nothing to drive yourself nuts over..give it a shot.
t-bonist
05-19-2006, 05:51 AM
Alritey.. tried n tested.. didnt quite come out rite.
No mail was sent, BUT, at least we solved the pop up window~! Hooray~!
Now to go ard this issue :rolleyes:
You could use senAndLoad() but you would have to return something from ASP to Flash
t-bonist
05-19-2006, 08:20 AM
Tried that, but i don't know how to go about retrieving data from .asp to .swf. Any advice?
t-bonist
05-19-2006, 09:10 AM
Hi Cota,
The solution has been found!
Actually it's what you told me in the earlier post. :)
Basically using sendAndLoad and store it in the original form function that was used to deliver data from .swf to.asp.
For those who are looking for this solution...
function sendForm() {
form = new LoadVars();
form.fname = name_txt.text;
form.email = email_txt.text;
form.novel = novel_txt.text;
form.sendAndLoad("Send2.asp", form, "POST");
}
Thank you Cota for ya advice, n Spillml for ya .fla codes :)
Cheers
t-bonist
Hey t-bonist.
Forgive me if I am imposing, but would you mind posting a zip file that contains your working files? Watered down, and your server details removed, ofcourse ;) hehe.
Its just that, since joining this thread, I still can't get mine to work.. :(
t-bonist
05-19-2006, 09:53 AM
Hey Morg,
Glad to be able help this community. :)
Here you go.
Cheers
t-bonist
Dear all,
I'm not a regular forummers in this forum and I know it inappropriate to ask for help without any contribution but I desperately needed one.
I did a google search and found this thread close to what I want however after attempting all that was mentioned, my problems still remain unsolved.
I'm have zero knowledge of asp but my actionscript is quite ok. I hoped you guys can help me out on this one. Thanks a lot
My problem is that i'm not receiving any mails from asp via flash. However the asp script works like a charm if trigger from HTML. I don't know what went wrong.
Here are the flash codes
function validateForm () {
var dSend = new LoadVars();
dSend.sname = mc.field0.field_ip.text;
dSend.semail = mc.field1.field_ip.text;
dSend.ssubject = mc.field2.field_ip.text;
dSend.smessage = mc.area.area_ip.text;
dSend.sendAndLoad( "enquiry.asp", dSend, "POST" );
}
Here are the asp codes
<%@ LANGUAGE="VBScript" %>
<%
'- Customization of these values is required. ------------------------------
referers = Array("www.credent-asia.com", "credent-asia.com")
smtpServer = "smtp.credent-asia.com"
fromAddr = Request("semail")
replyTo = Request("semail")
recipients = "dataware@credent-asia.com"
subject = Request("ssubject")
'- End required customization section. -------------------------------------
Response.Buffer = true
errorMsgs = Array()
'Build table of form fields and values.
body = "<table border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
for each name in fieldOrder
body = body _
& "<tr><td><font size=""2"" face=""Arial, Helvetica, sans-serif"">Name: " & Request("sname") & "</font></td></tr>" _
& "<tr><td><font size=""2"" face=""Arial, Helvetica, sans-serif"">" & Request("smessage") & "</font></td></tr>" _
& vbCrLf
next
body = body & "</table>" & vbCrLf
'Send it.
str = SendMail()
%>
<% '---------------------------------------------------------------------------
' Subroutines and functions.
'---------------------------------------------------------------------------
function SendMail()
dim cdoMessage, cdoConfig
'Send email (CDOSYS version).
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
cdoConfig.Fields.Update
set cdoMessage.Configuration = cdoConfig
cdoMessage.From = fromAddr
cdoMessage.ReplyTo = replyTo
cdoMessage.To = recipients
cdoMessage.Subject = subject
cdoMessage.HtmlBody = body
on error resume next
cdoMessage.Send
set cdoMessage = Nothing
set cdoConfig = Nothing
exit function
end function %>
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.