Link to home
Create AccountLog in
Avatar of awinstead
awinsteadFlag for United States of America

asked on

Sending Emails from Flash using Javascript popup window and Persits MailSender

Hello,
I am trying to send data via Macromedia Flash to an ASP page. The problem I have is, the value's entered into the text fields don't carry over. I get a blank email that is sent. Here is the code I am using If I don't use the javascript pop up windo it works fine. So I am wondering if the Javascript is killing it and how?

Any help would be greatly appreciated.

In the flash HTML

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Launch(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=393,height=435");
}
// End -->
</SCRIPT>




In my ASP page that sends the email. the ISP Requires login and password info inside.

<%
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 = Server.CreateObject("Persits.MailSender")
MyMail.Host = "mail.emailaddress.com"
MyMail.body = myBody
MyMail.IsHTML = True
MyMail.From = request.form("email")
MyMail.Username = "test@emailaddress.com"
MyMail.Password = "test"
MyMail.AddAddress "test@emailaddress.com"
MyMail.Subject = "test"
'MyMail.AddCC "Valid@emailaccount.com"

If MyMail.Send Then
     Response.Write("Message Sent.")
Else
     Response.Write("Message Not Sent.")
End If
Set MyMail = Nothing
%>




The Macromedia Flash Button. The flash movie has three input text fields for one for email address, one for subject and one for body.

on (release) {
      getURL("javascript:Launch('basic_mail.asp')" ,"",  "POST");
}
Avatar of Buffon
Buffon
Flag of Israel image

why wont you open the asp directly from flash?

getURL("basic_mail.asp","_blank",  "POST");
Avatar of fixitben
fixitben

Ok I think you are going about this the wrong way.

What I see you want to do is open a pop up window with the flash file in it right.
That is called basic_mail.asp and that has the code to email and everything.

What you need to do is create just a regular html file with the flash file in it and have the pop up pull that up then have a totally separte page called basic_mail.asp and have your code in it that you post above

<%
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 = Server.CreateObject("Persits.MailSender")
MyMail.Host = "mail.emailaddress.com"
MyMail.body = myBody
MyMail.IsHTML = True
MyMail.From = request.form("email")
MyMail.Username = "test@emailaddress.com"
MyMail.Password = "test"
MyMail.AddAddress "test@emailaddress.com"
MyMail.Subject = "test"
'MyMail.AddCC "Valid@emailaccount.com"

If MyMail.Send Then
     Response.Write("Message Sent.")
Else
     Response.Write("Message Not Sent.")
End If
Set MyMail = Nothing
%>

Then on the submit button for the flash file

have this

on(release)
{loadVariablesNum ("basic_mail.asp", "0", "Post");
}

This works great for me

http://theyac.org/indexlow.html

Click on prayer request this is one of my working ones.


Fixitiben
Avatar of awinstead

ASKER

The reason I am using a Javascript is because the "thank you for sending" page will pop open after they submit the flash piece. The "thank you for sending" page is also basic_mail.asp and it send the values to the smtp server. The owner had requested that pop up box be a small box that shows their logo and says thank you for sending etc...

So I could strip out the javascript but then I lose the ability to set the height, width etc...

Is there anyway to keep the javascript and yet still have the data post to the smtp server?
you can submit data to smtp server with asp page without opening it with loadVariables from flash, after you get response from this page, you can popup a simple html page with thank you with javascript:Launch('thankyou.html')
I am not 100% on how this would be done? Would you have an example that I might be able to look at?

All your help is greatly appreciated.
I will work on something tonight.  But basically you need to return a value back from the asp page then once it recieves that value it will getURL and do the pop up with the thanks page.  

Or if you wanted to you could just keep it all in flash and once that value is returned it just goes to a different frame with thanks and the pic and stops that way you wouldn't have to mess with the pop up window at all.

But I will come up with an example tonight to show you.

Fixitben
Could you post your fla so I can just work with that instead of just recreating a new one?

Thanks
Fixitben
ASKER CERTIFIED SOLUTION
Avatar of fixitben
fixitben

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer