Solved

Sending Flash variables to email using ASP

Posted on 2008-10-01
8
649 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
ID: 22620970
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
ID: 22627741
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
ID: 22630284
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:wtran
ID: 22631307
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
 
LVL 10

Expert Comment

by:slamhound
ID: 22631362
What does reset_txt do?

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

Author Comment

by:wtran
ID: 22635132
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
ID: 22638971
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
ID: 22646529
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Group by correlation 4 57
File conversion question 5 103
Change visitor's REMOTE_ADDR to server's REMOTE_ADDR 2 30
Issues with Insert statement 12 25
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

808 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