PDA

View Full Version : Send e-mail with ASP-take two


Rachel Ann
08-20-2006, 11:58 PM
Okay here we go. Scratch what I asked about PHP earlier. I got my people to change the server. Now I have a different problem. And this is so confusing.

So we (Cota) got the ASP and AS to work last time with the server I was testing on. This is what is happening now:

I click send, and it say "Email sent" in the status box (so it reads the ASP) but it doesn't send the e-mails.

So you may be thinking...oh, well the new server has a problem with the ASP. But, I tried the the simple tuturial flash and it works...on the exact same ASP file in the exact same location.

So then I thought maybe the AS wasn't working right, but nope. If you direct it towards the first server I used it works. AND when I put the exact same AS in my flash file into the tutorial file, it sends the e-mail.

So it seems as if the ASP file works and the AS works, but not together on the new server.

Does this make sense? What in the world is going on here?

Here is what I am using:

AS:

//Create a loadvars object named email_lv
var email_lv = new LoadVars();

//this function is called when email_lv loads the server-side script.
email_lv.onLoad = function(success) {
//If the script was successfully loaded, this condition is run
if (success) {


if (email_lv.server_mes == "ok") {

status_txt.text = "Email Sent";

}
} else {
//email failed to send, but script did load. Likely a server issue.
status_txt.text = "Email Failed";
}
};


submit_btn.onRelease = function() {


if (!email_txt.length || email_txt.indexOf("@") == -1 || email_txt.indexOf(".") == -1) {
status_txt.text = "Invalid Email.";

//This validates the subject line contains text
} else if (!name_txt.length) {
status_txt.text = "Missing Name";

//This validates the message body contains text
} else if (!phone_txt.length) {
status_txt.text = "Missing Phone";


} else if (!message_txt.length) {
status_txt.text = "Missing Message";


} else {

email_lv.email_txt = email_txt.text;
email_lv.name_txt = name_txt.text;
email_lv.phone_txt = phone_txt.text;
email_lv.message_txt = message_txt.text;

email_lv.sendAndLoad("http://www.thehousenlr.com/SendMail.asp", email_lv, "POST");
}
};
stop();


ASP:


<%
dim themail, thename, themessage, i

'Gets the incoming variables from flash
themail = Request("email_txt")
thename = Request("name_txt")
thephone = Request("phone_txt")
themessage = Request("message_txt")

'Decalre and create email object
dim objmail

set objmail = Server.CreateObject("CDONTS.Newmail")
'error handler, if error encountered, ignore it and proceed
On Error resume next

'build the email using the variables from flash
objmail.From = themail
objmail.To = "[email protected]"
objmail.Subject = "Email from thehouse website"
objmail.Body = "The following is a message from " & thename & " (phone number " & thephone & ") from thehouse website: " &themessage
objmail.Send
'error handler, if error encountered, ignore it and proceed
On Error resume next

'If any errors were encounter then run this code
If Err.Number <> 0 then
'tells flash ASP failed and terminates the ASP file.
Response.Write "&server_mes=fail"
Response.End
else
'Send message back to flash saying everything was ok.
Response.Write "&server_mes=ok"
End if

%>

Cota
08-21-2006, 12:26 AM
Same thing as before..have you checked the spam box..

Rachel Ann
08-21-2006, 12:29 AM
yep, i checked it. it's not in the spam box.

Cota
08-21-2006, 01:44 AM
In the ASP file, hard code the values and run the ASP file on the server..see if it send the email..

Rachel Ann
08-21-2006, 01:56 AM
do you mean like, put in a name instead of using the variable thename?

i know that the asp works on the server...it has sent an e-mail when i used the tutorial swf.

Cota
08-21-2006, 02:01 AM
Yes, hard code the values...then hit the file directly.

Rachel Ann
08-21-2006, 02:05 AM
it sent an e-mail.

Cota
08-21-2006, 02:07 AM
hmm...ok...are we sure all the values are getting to the ASP script?

Rachel Ann
08-21-2006, 02:10 AM
how do i find that out?

the server sends back a response that makes the status field change to e-mail sent...?

the exact AS works when i copy and past into your tutorial. and it works when change it to look at the ASP from the other server that we got to work last time.

the only thing i did was move everything to the new server...which apparently likes my ASP still but doesn't like my swf and ASP to work together.

Cota
08-21-2006, 02:15 AM
Set it all back to the original code in the ASP, basically undoing the hard code values....Now, change it to this

Response.Write "&server_mes=ok"
Response.Write "&mail_mes="&themail

and add that mail_mes to the statusbox in flash.

Rachel Ann
08-21-2006, 02:21 AM
k i changed the ASP,

now I change the AS from:

if (email_lv.server_mes == "ok") {

status_txt.text = "Email Sent";

}

to

?


sorry, i'm don't know the syntax. i'm a beginner on programming.

Cota
08-21-2006, 02:25 AM
status_txt.text = "Email Sent"; should read

status_txt.text = this.mail_mes;

Rachel Ann
08-21-2006, 02:30 AM
ok. the status said what i put inside the email field instead of e-mail sent...which i guess is what we were looking for.

so this means that the variables are getting there, i guess?

Cota
08-21-2006, 02:32 AM
so values are being sent...now I'm just lost...

Rachel Ann
08-21-2006, 02:34 AM
oh no! lol...don't say that :-D

Cota
08-21-2006, 02:41 AM
I'll think about it, but I honestly dont know what would cause that, unless there was an error with the email address or a serious delay in the SMTP on that server..

Rachel Ann
08-21-2006, 02:44 AM
hmm...ok.

the e-mail address is right b/c it works on the ualr server.

delay...maybe...but it worked when we hit it.

oh...i just realized something. it was doing the same thing with the tutorial. i still had it going to the ualr server instead of the new one. So sending variables but no e-mail.

Flash Gordon
08-21-2006, 02:44 AM
Rachel,

Did you try what I mentioned in your other thread?

Rachel Ann
08-21-2006, 02:45 AM
the php thing? no, because i'm doing asp now... or did i miss something else?

Cota
08-21-2006, 02:46 AM
hmm...ok.

the e-mail address is right b/c it works on the ualr server.

delay...maybe...but it worked when we hit it.

oh...i just realized something. it was doing the same thing with the tutorial. i still had it going to the ualr server instead of the new one. So sending variables but no e-mail.

what do you mean?

Rachel Ann
08-21-2006, 02:47 AM
i said earlier that worked with ur tutorial, but it doesn't.

Rachel Ann
08-21-2006, 02:50 AM
i'm hosting this on a go daddy server if means anything...

Rachel Ann
08-21-2006, 03:14 AM
have y'all given up...:-D

:(

Flash Gordon
08-21-2006, 03:30 AM
Why don't you give someone all the source files, give them admin rights to your server, and pay them $50 to fix it for you?

Anybody could have this workin' within 20 minutes.

Rachel Ann
08-21-2006, 03:40 AM
Why don't you give someone all the source files, give them admin rights to your server, and pay them $50 to fix it for you?

Anybody could have this workin' within 20 minutes.

Ummm...ok...

This sounds a little, uh, testy to me I guess. I don't know if you intended it to be that way or not. But, we got this working last time, so I thought maybe y'all could do it again. If y'all have done all you can do that's fine, or if you are just tired that's fine too. I just wanted to make sure y'all weren't still working before I left for the night. I'd wouldn't want for you to have something for me to try and then me not be here. Anyway...sorry if I was too pushy...just curious as to what's going on...

Flash Gordon
08-21-2006, 03:47 AM
you've been at this for over a month. Some things are worth to pay people for. The amount of time you have already put into it has to be worth more than $50...

Rachel Ann
08-21-2006, 03:52 AM
3 days actually. and it's not my website--I'm voluteering and do not have the authority to do so, but I will suggest it.

Flash Gordon
08-21-2006, 03:54 AM
http://actionscript.org/forums/showthread.php3?t=105112

posted 4 months ago!

EDIT: Sorry if you take offense. I know if I was working of something for 3-4 months and tried all tutorials and suggestions, I'd just pay someone else a measly 50 to do it. But it is your call, Cota is a really nice guy (more so than me) and I'm sure he'll stick with you to the end, but like I said in my other post in the other thread, it is impossible to solve this if it is a server issue.

Good luck and best wishes.

Cota
08-21-2006, 04:03 AM
I honestly just dont have an answer at this point...the code is fine..just something screwy...

Rachel Ann
08-21-2006, 04:06 AM
ok. thanks. i'll wait in the meantime i guess.

Flash Gordon
08-21-2006, 04:10 AM
hmm...ok...are we sure all the values are getting to the ASP script?
Use getURL("mail.asp", "_blank", "POST");

and "write" out all of the posted data. You can physically see what is happening. Additionally, here is a great little tool http://livehttpheaders.mozdev.org/screenshots.html
for such a thing.

Rachel Ann
08-21-2006, 04:25 AM
we decided that the variables are getting there...

Flash Gordon
08-21-2006, 04:34 AM
:rolleyes:

Good luck and best wishes.

Rachel Ann
08-21-2006, 05:14 AM
Ok...godaddy provided a form mailer thing. And I directed it to that and it sent me an e-mail like this:

email_txt: [email protected]
message_txt: this is a test
name_txt: Rachel
onLoad: [type Function]
phone_txt: 555-5555
-----------------------------------------------------------------
This e-mail was generated from a form submission on your website: thehousenlr.com

Which, I guess is okay, but not ideal. It would be better if I could make this send back something to put in the status_txt field.

Here is the form mailer:


ASP:
<%

Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty
On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("ssfm")
dirname = filename
filename = filename & "/gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)

Function FormatVariableLine(byval var_name, byVal var_value)
Dim tmpStr
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
tmpStr = tmpStr & var_value & vbCRLF
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
FormatVariableLine = tmpStr
end function

Sub OutputLine(byVal line)
outfile.WriteLine(line)
end sub

if err.number = 0 then
Set outfile = fso.CreateTextFile(filename, true, false)
if err.number <> 0 then
bErr = true
errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
else
if(req_method = "GET") then
for each Item in request.QueryString
if item <> "" then
bEmpty = false
key = item
value = Request.QueryString(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
elseif (req_method = "POST") then
for each Item in request.form
if item <> "" then
bEmpty = false
key = item
value = Request.form(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
end if
outfile.close
end if
if(bEmpty = true) AND errStr = "" then
bErr = true
errStr = errStr & "<br>No variables sent to form! Unable to process request."
end if
if(bErr = false) then
if (landing_page <> "") then
response.Redirect "http://" & host_url & "/" & landing_page
else
response.Redirect "http://" & host_url
end if
else
Response.Write errStr
end if
set fso = nothing
else
Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if
%>