Sending mail from flash
Ok with much help from Kglad Ned and Raymond i have a working ASP file that sends a email but as is it gets all input from HTML form i have tryed to revise it to get information from flash but nothing happens The origenal asp is as follows...
<% 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>
THIS WORKS PERFECTLY
i have tryed to omit the HTML like this:
<% 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
%>
and contact it with this flash AS3:
stop();
emailfrom_txt.text = "someone@somewhere.com";
emailto_txt.text = "someone@somewhere.com";
emailbody_txt.text = "";
emailsubject_txt.text = "";
htmlbody_txt.text = "";
submit_btn.addEventListener(MouseEvent.CLICK, sendInfo);
var emailfrom = emailfrom_txt.text;
var emailto = emailto_txt.text;
var emailsubject = emailsubject_txt.text;
var emailbody = emailbody_txt.text;
var htmlbody = htmlbody_txt.text;
function sendInfo (e:MouseEvent):void{
var varSend:URLRequest = new URLRequest("mailer4.asp");
varSend.method = URLRequestMethod.GET;
var urlVar:URLVariables=new URLVariables();
urlVar.sFrom = emailfrom;
urlVar.sTo = emailto;
urlVar.sSubject = emailsubject;
urlVar.sTextBody = emailbody;
urlVar.sHTMLBody = htmlbody;
varSend.data=urlVar;
var urlLDR:URLLoader=new URLLoader();
urlLDR.addEventListener(Event.COMPLETE,completeF);
urlLDR.load(varSend);
}
function completeF(e:Event){
trace("COMPLETE");
trace(URLLoader(e.target).data);
trace (emailto, emailfrom, emailsubject, emailbody, htmlbody);
}
what did i miss?
