Skip to main content
JDBird1000
Known Participant
July 29, 2009
Answered

mailing test results from flash + asp

  • July 29, 2009
  • 2 replies
  • 4899 views

Ok so this is a problem i have been suck on for two months now tryed every tutorial and example i can find and cant get this to send a email.

here is the code i have:

Flash/AS3:

stop();

submit_btn.addEventListener(MouseEvent.CLICK, sendInfo);

var emailfrom:String = "someone@somewhere.com";
var emailto:String = "someone@somewhere.com";
var emailsubject:String = "test message";
var emailbody:String = "this is a test message";
 
function sendInfo (e:MouseEvent):void{
 
  var varSend:URLRequest = new URLRequest("mailer.asp");
  varSend.method = URLRequestMethod.POST;
  varSend.data = (emailfrom,emailto,emailsubject,emailbody);
  }

//what can i add to this to see if it is connecting to the  .asp file?????

THIS is the .asp

<.asp>
<head>
<title>Emailer ASP</title>
<meta http-equiv="Content-Type" content="text.asp; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<%

Dim strFrom, strTo, strSubject, strBody

strFrom = Request.Querystring("emailfrom")
strTo = Request.Querystring("emailto")
strSubject = Request.Querystring("emailsubject")
strBody = Request.Querystring("emailbody")

Dim MyMail
Set MyMail = Server.CreateObject("smtp.somewhere.com")

MyMail.From = strFro
MyMail.To = strTo
MyMail.Subject = strSubject
MyMail.Body = strBody
MyMail.Send

Set MyMail = Nothing

%>

Your email has been sent.

</body>
&lt;.asp&gt;

Nothing happens when i hit the send button can anyone tell why.... I just got off phone with web host provider and they do support asp and i do have the correct SMTP

This topic has been closed for replies.
Correct answer kglad

Ray i got the asp file you wrote to work by making one change but because of the way you built it... and my extream Nub ness i can change it to run from flash sending the email body and subject

<% Option Explicit %>
<%
'Declare variables
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
Dim sHTMLBody

Dim confSendUsing
Dim confServer
Dim confPort

confSendUsing = 2
confServer = "smtp.tde.com" 'SMTP server name or Ip address
confPort=25

'Get data from previous page
sTo = Request("sTo")
sFrom = Request("sFrom")
sSubject = Request("sSubject")
sTextBody = Request("sTextBody")
sHTMLBody = Request("sHTMLBody")

'Only run this if it's not the first time
If Request.Form("Submit") <> "" Then

Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")
'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = sTextBody
objMail.HTMLBody = sHTMLBody


objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=confSendUsing
'Name or IP of remote SMTP server
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")= confServer
'Server port
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=confPort
objMail.Configuration.Fields.Update


'Send the email
objMail.Send
'Set sMsg which will be used later
sMsg = "Your message was sent to: " & sTo

'Clean-up
Set objMail = Nothing

End If
%>
<html>
<head><title>SendMail</title></head>
<body>
<form action="<%=Request.ServerVariables("PATH_INFO")%>" method="post">
  <table>
    <tr>
      <td>Send To:</td>
      <td><input type="text" name="sTo" value="<%=sTo%>"></td>
    </tr>
    <tr>
      <td>Send From:</td>
      <td><input type="text" name="sFrom" value="<%=sFrom%>"></td>
    </tr>
   <tr>
      <td>Message Subject:</td>
      <td><input type="text" name="sSubject" value="<%=sSubject%>"></td>
    </tr>
    <tr>
      <td>Message Text Body:</td>
      <td><textarea cols="60" rows="5" name="sTextBody">
         <%=sTextBody%></textarea></td>
    </tr>
    <tr>
      <td>Message HTML Body:</td>
      <td><textarea cols="60" rows="5" name="sHTMLBody">
         <%=sHTMLBody%></textarea></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
  <hr>
  <%=sMsg%>
  </form>
</body>
</html>


so, this thread is answered?

2 replies

July 29, 2009

Your ASP code uses Request.Querystring to retrieve the values sent to the page. The QueryString collection parses the data sent using the GET method. You're using URLRequestMethod.POST to send the data.

Either use URLRequestMethod.GET on the client side or use Request.Item or Request.Form on the server.

JDBird1000
Known Participant
July 29, 2009

Ok changed to :

...

function sendInfo (e:MouseEvent):void{

var varSend:URLRequest = new URLRequest("mailer.asp");

varSend.method = URLRequestMethod.GET;

var urlVar:URLVariables=new URLVariables();

urlVar.emailfrom=emailfrom;

urlVar.emailto=emailto;

urlVar.emailsubject=emailsubject;

urlVar.emailbody=emailbody;

}

But still nothing... THIS has become the hardest thing I have had to do in flash yet!!!!!! ((o.O))

kglad
Community Expert
Community Expert
July 29, 2009

...

function sendInfo (e:MouseEvent):void{

      var varSend:URLRequest = new URLRequest("mailer.asp");

      varSend.method = URLRequestMethod.GET;

     var urlVar:URLVariables=new URLVariables();

urlVar.emailfrom=emailfrom;

urlVar.emailto=emailto;

urlVar.emailsubject=emailsubject;

urlVar.emailbody=emailbody;

varSend.data=urlVar;

var urlLDR:URLLoader=new URLLoader();

urlLDR.load(varSend);
}
kglad
Community Expert
Community Expert
July 29, 2009
  varSend.data = (emailfrom,emailto,emailsubject,emailbody);

isn't right.

you should be doing something like:

var urlVar:URLVariables=new URLVariables():

urlVar.emailfrom=emailfrom;

urlVar.emailto=emailto;

etc.

varSend.data=urlVar;

JDBird1000
Known Participant
July 29, 2009

varSend.data = (emailfrom,emailto,emailsubject,emailbody);

isn't right.

you should be doing something like:

var urlVar:URLVariables=new URLVariables(): <---- is this supposed to be a ";"?

urlVar.emailfrom=emailfrom;

urlVar.emailto=emailto;

etc.

varSend.data=urlVar;