Solved

Sending Flash variables to email using ASP

Posted on 2008-10-01
8
647 Views
Last Modified: 2010-08-05
Hi,
I've been stumped for the last while. Need help on this problem. I have a flash movie that I have published in an html. The Flash has a form that "onRelease" sends the form variables to a mailer.asp page for processing through SMTP mail on the server. The server is running MS Server 2003. When I fill out the form in the flash site and hit the send button I get the email but the variables are not sent. I only get (Name:_____, Email:______ etc). I have a code problem here.

Thanks All!!
Flash : On Release

==================================================

on (release) {

	for (i=1; i<_parent.fields_descriptions.length; i++) {

		this[_parent.fields_descriptions[i][2]] = _parent[_parent.fields_descriptions[i][1]];

		_parent.reset_txt(_parent["t"+i], _parent.fields_descriptions[i][1], _parent.fields_descriptions[i][2]);

	}

	this.recipient = _parent.rec;

	i = undefined;

	this._parent.getURL("mailer.asp", "", "POST");

}

=================================================
 

ASP Mailer : Mailer.asp
 

<%

'Email ASP Code 

'--------------------------------------------------------

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
 

'Change this RemoteHost to a valid SMTP address before testing

Mailer.RemoteHost  = "smtp.mailserver.ca"

Mailer.FromName  = Request("t1")+" " +Request("t2")

Mailer.FromAddress = "info@mailserver.ca" 

Mailer.AddRecipient  "Title", "test@mailserver.ca"
 

Mailer.ReturnReceipt = true

Mailer.Subject     = "Seacan Website Inquiry"

Mailer.BodyText    = "Name : " + Request("t1")

Mailer.BodyText    = "E-Mail : " + Request("t2")

Mailer.BodyText    = "Phone : " + Request("t3")

Mailer.BodyText    = "Message : " + Request("t4")
 
 

if not Mailer.SendMail then

  Response.Write " Mailing Failed... Error is: <br>"

  Response.Write Mailer.Response

else

  Response.write "<center><font color=blue>"

  

end if

%>

<html>

<head>

<title>E-Post Message Sent</title>

</head>
 

<body bgcolor="#FFFFE8">

<p align="center"><font face="Century Gothic" size="5">Message Sent</font>

<p align="center"><font size="3" face="Arial"><a href="sendmail1.htm" target="_top">Return

to the Send Mail tutorial</a></font></p>

</body>

</html>

Open in new window

0
Comment
Question by:wtran
  • 4
  • 4
8 Comments
 
LVL 10

Expert Comment

by:slamhound
Comment Utility
I'm no Flash expert but I can see where ASP is not getting your variables.

You need something like:
this._parent.getURL("mailer.asp?t1=Fred&t2=Smith", "", "POST");

with Fred and Smith being from your variables.

I just can't see where you are passing the variables in your flash code.
0
 

Author Comment

by:wtran
Comment Utility
Thanks, how do I pass variables from flash to the mailer.asp Page.  If I hard code "Fred" and "Smith". That seems to work.

Any idea how I could get this to work?

Thanks in advance.
0
 
LVL 10

Expert Comment

by:slamhound
Comment Utility
Depends on what your variables are but you could try something like...

this._parent.getURL("mailer.asp?t1=" + this.recipient + "&t2=" + this.recipient, "", "POST");

Replace "this.recipient" with your variables and replace "+" with whatever Flash uses to join strings together.
0
 

Author Comment

by:wtran
Comment Utility
Thanks, yes I've tried this and all I get now is the variable that I'm trying to pass says that it is undefined. Then it puts the word "undefined" where the variable should be.  I tried request(t1), this.t1, this._parent.t1.  All with the same results.

The variables are on a flash form. (var t1)

Are there other ways of getting variables from a flash form ?

Thanks again
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Expert Comment

by:slamhound
Comment Utility
What does reset_txt do?

Try _parent["t1"] or _parent.fields_descriptions[1][1]
0
 

Author Comment

by:wtran
Comment Utility
I tried _parent["t1"] and nothing was returned.  Then I tried _parent.fields_descriptions[1][1] and "T1" was returned.

Anything else I could try?

Tks

Will
0
 

Author Comment

by:wtran
Comment Utility
Hello Experts, perhaps more info is required

This here would be my initial load:
//==================================
rec="test@test.com";
serv="asp";

var fields_descriptions= Array ("",
                                                      Array("t1", "yname", "Your Name:"),
                                                      Array("t2", "yemail", "Your Email:"),
                                                      Array("t3", "tphone", "Telephone:"),
                                                      Array("t4", "message", "Message:")                                                                                          );
function reset_txt(name,name2,value) {
            path=eval(_target);
            path[name2]="";
}
for (i=1; i<=fields_descriptions.length; i++) {
      reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
}

//==================================

Then this is my submit button

//==================================
onClipEvent (enterFrame) {
      if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
            if (this._currentframe<this._totalframes) {
                  this.nextFrame();
            }
      } else {
            if (this._currentframe>1) {
                  this.prevFrame();
            }
      }
}
on (release) {
      for (i=1; i<_parent.fields_descriptions.length; i++) {
            this[_parent.fields_descriptions[i][2]] = _parent[_parent.fields_descriptions[i][1]];
            _parent.reset_txt(_parent["t"+i], _parent.fields_descriptions[i][1], _parent.fields_descriptions[i][2]);
      }
      this.recipient = _parent.rec;
      i = undefined;
      getURL("mailer."+_parent.serv, "_blank", "POST");
}
//=======================================

Then this is my ASP page.

//=========================================

<%
'Email ASP Code
'--------------------------------------------------------
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

'Change this RemoteHost to a valid SMTP address before testing
Mailer.RemoteHost  = "smtp.seacan.ca"
Mailer.FromName  = Request("yname")+" " +Request("yemail")
Mailer.FromAddress = "test@test.com"
Mailer.AddRecipient  "name", "test@test.com"

Mailer.ReturnReceipt = true
Mailer.Subject     = "Website Inquiry"
Mailer.BodyText    = "Name : " + Request("yname")
Mailer.BodyText    = "E-Mail : " + Request("yemail")
Mailer.BodyText    = "Phone : " + Request("tphone")
Mailer.BodyText    = "Message : " + Request("message")


if not Mailer.SendMail then
  Response.Write " Mailing Failed... Error is: <br>"
  Response.Write Mailer.Response
else
  Response.write "<center><font color=blue>"
 
end if
%>
<html>
<head>
<title>Seacan E-Post Message Sent</title>
</head>

<body bgcolor="#FFFFE8">
<p align="center"><font face="Century Gothic" size="5">Message Sent</font>
<p align="center"><font size="3" face="Arial"><a href="http://www.seacan.ca" target="_top">Return
to Seacan Online</a></font></p>
</body>
</html>
//==========================

My issue is that the email is sent, I get confirmation that the email is sent.  But I'm having problems getting the variables from the flash page to the ASP page.  I've tried request(XXXX), POST, GET.  

I am exporting it out as Flash 8.0 on Flash CS3

Thanks in advance.
0
 
LVL 10

Accepted Solution

by:
slamhound earned 500 total points
Comment Utility
ah! An array of data! Makes more sense now. :)

this._parent.getURL("mailer.asp?yname=" + _parent.fields_descriptions[1][2] + "&yemail=" + _parent.fields_descriptions[2][2]", "", "POST");

This assumes that arrays in Flash are zero based. so [1][2] = "Your Name" and [2][2] = "Your Email"

Just make sure that this isn't deleting all the variables:
for (i=1; i<=fields_descriptions.length; i++) {
      reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
}
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now