PDA

View Full Version : ASP feedback problem



camaleon
May 5th, 2005, 11:27 AM
hi guys.
i download a asp code, work but i want put more textfield.

well i have a problem with this script, well the code work fine send the mail BUT just send 1 textfield the MESSAGE.

i want that in the mail appear all my textfield inside the mail message.

and too! i want when send the mail dont appear a message that say Message Sent and just want that open inside the page index.html.
---------------------------------------------------------------------

<%
If request("submit") <> "" THEN
Set objEMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "mymail@mail.com"
objEMail.From = "feedback@my.com"
objEMail.Subject = Request("subject")
objEMail.TextBody = Request("email")
objEMail.TextBody = Request("phone")
objEMail.TextBody = Request("topic")
objEMail.TextBody = Request("message")
objEMail.Send
Set objEMail = Nothing
Response.Write("Message Sent")
Else
%>
<FORM ACTION="this.asp" METHOD=POST>
<input name="subject" type="text" id="subject">
<br>
<input name="email" type="text" id="email">
<br>
<input name="phone" type="text" id="phone">
<br>
<input name="topic" type="text" id="topic">
<br>
<textarea name="message" rows="5" id="message"></textarea>
<br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
<br>
</form>
<%
End If
%>

prstudio
May 6th, 2005, 02:19 AM
objEMail.TextBody = Request("email")
objEMail.TextBody = objEMail.Textbody & Request("phone")
objEMail.TextBody = objEMail.Textbody & Request("topic")
objEMail.TextBody = objEMail.Textbody & Request("message")

^ that should work.

The reason it kept just giving you the "message" field was because as you had it originally you kept redefining the objEMail.Textbody variable. You set it to equal to something and then immediately on the line below that set it equal to something completely else. As you read the code it literally means objEMail.Textbody = objEmail.Textbody(as we just defined it) & (AND) Request("Field") (additional value)

The above code would return something like this as the message body.
5555555TopicMessage - unformatted...

Now this kind of email handling is kind of "dated" in my opinion. Most ASP servers use something called "Persits Mail Sender"

Here is the code using Persits Mail Sender with more formatting involved.

<%
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.YOURSERVER.com" ' Specify a valid SMTP server
Mail.From = "YourAccount@YOURSERVER.com" ' Specify sender's address
Mail.FromName = "Website Contact" ' Specify sender's name

Mail.AddAddress "AnotherAccount@YOURSERVER.com" 'Carbon Copy someone else



Mail.Subject = "Message from your website!"
Mail.Body = "Website visitor wrote!" & Chr(13) & Chr(10) & _
Chr(13) & Chr(10) & _

"Message: " & request.form("message") & " "

On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
' your site or some confirmation page
Response.Redirect "http://www.yourserver.com/"
%>


on that last set of code - often times for the SMTP you have to put in your server's actual IP address. If you don't and if the account this web message is "supposedly" sending from isn't local you will get an error 550 "relaying denied"

hope this helps :)

ps> the spacing might have messed up the code i put in the [code] tags - so work with it.

camaleon
May 7th, 2005, 10:52 AM
thanks so much prstudio :)

prstudio
May 7th, 2005, 04:47 PM
no problem :)

kay2464
June 27th, 2005, 08:26 PM
Hi all,
I have the following action script code for an email form using ASP. Problem is that I'm not able to get email, though all else works fine. The ASP is working on it's own for sending email... so I can only imagine I'm missing something below in the as...?
Can someone help, pleaseeeeeeeee?

actionscript code:

submitURL = "/handleSubmitC.asp";
// New style sheet
kStyle = new FStyleFormat();

// Attributes of the style sheet
kStyle.face = 0xBF0000;
kStyle.background = 0xBF0000;
kStyle.arrow = 0xCC6699;
kStyle.scrollTrack = 0xBF0000;
kStyle.highlight = 0xBF0000;
kStyle.darkshadow = 0xBF0000;
kStyle.selection = 0xBF0000;
kStyle.textColor = 0xBF0000;

// apply kStyle to the components
kStyle.addListener(salon);
kStyle.addListener(phone);
kStyle.addListener(email);
kStyle.addListener(address);
kStyle.addListener(city);
kStyle.addListener(statecounty);
kStyle.addListener(zip);
kStyle.addListener(bar);
kStyle.addListener(country);
kStyle.addListener(color);
kStyle.addListener(color_label);
kStyle.addListener(placement);
kStyle.addListener(trends);
kStyle.addListener(corrective);
kStyle.addListener(motivation);
kStyle.addListener(look);
kStyle.addListener(submit);
kStyle.addListener(reset);

// textbox
comment.backgroundColor = 0xFFFFFF;

//tabbing structure
name_f.tabIndex = 1;
salon_f.tabIndex = 2
phone_f.tabIndex = 3;
email_f.tabIndex = 4;
address_f.tabIndex = 5;
city_f.tabIndex = 6;
statecounty_f.tabIndex = 7;
zip_f.tabIndex = 8;
country_f.tabIndex = 9;
comment.tabIndex = 10;
submit.tabIndex = 11;


// Scrollbar
// The textarea is empty, so no scrollbar
bar._visible=false;
// onChanged function
comment.onChanged = function(){
if (this.maxscroll>1) {
bar._visible=true;
}
else bar._visible=false;
}



// 4. Checkbox
// Array of the instance names of the checkboxes
myCheck = [color,placement,trends,corrective,motivation,look];

// Function
function checkDisplay(component) {
var j,s;
for(j in myCheck){
if(myCheck[j].getValue()) s += myCheck[j].getLabel()+"\n";
}
checke = "\nCOURSE(S) OF INTEREST:\n" + ((s.length) ? s : "None");
}

// As usual...
for (i=0;i<myCheck.length;i++) {
myCheck[i].setChangeHandler ("checkDisplay") ;
}


// Push Buttons
// Reset button function
function onReset() {
// text
comment.text = "";
name_f.text = "";
salon_f.text = "";
phone_f.text = "";
email_f.text = "";
address_f.text = "";
city_f.text = "";
statecounty_f.text = "";
zip_f.text = "";
country_f.text = "";
bar._visible = false;

// checkbox
var j;
for (j in myCheck) {
myCheck[j].setValue(false);
}

}

// Submit button function
function onSubmit() {
formData = new LoadVars();
formData.texte = "";
formData.name = "";
formData.salon = "";
formData.phone = "";
formData.email = "";
formData.address = "";
formData.city = "";
formData.satecounty = "";
formData.zip = "";
formData.country = "";
formData.myCheck = "";


replyData = new LoadVars();

// Initialize reply variable.
replyData.reply_texte = "";
replyData.reply_name = "";
replyData.reply_salon = "";
replyData.reply_phone = "";
replyData.reply_email = "";
replyData.reply_address = "";
replyData.reply_city = "";
replyData.reply_statecounty = "";
replyData.reply_zip = "";
replyData.reply_country = "";
replyData.reply_myCheck = "";

replyData.onLoad = handleReply;


// Submit the order data
formData.sendAndLoad(submitURL, replyData, "post");


}
function handleReply(success) {
if(success == true) {
gotoAndStop ("result");
result.text+= "NAME: "+name;
result.text+= "\nSALON: "+salon;
result.text+= "\nPHONE: "+phone;
result.text+= "\nEMAIL: "+email;
result.text+= "\nADDRESS: "+address;
result.text+= "\nCITY: "+city;
result.text+= "\nSTATE / COUNTY: "+statecounty;
result.text+= "\nZIP CODE: "+zip;
result.text+= "\nCOUNTRY: "+country;
result.text+= "\n" +checke;
result.text+= "\nCOMMENTS / QUESTIONS:\n"+texte;
} else {
gotoAndStop ("error");
result.text = "There was a problem submitting your information.\nPlease try again later.";
}
}

prstudio
June 28th, 2005, 04:22 AM
// Initialize reply variable.
replyData.reply_texte = "";
replyData.reply_name = "";
replyData.reply_salon = "";
replyData.reply_phone = "";
replyData.reply_email = "";
replyData.reply_address = "";
replyData.reply_city = "";
replyData.reply_statecounty = "";
replyData.reply_zip = "";
replyData.reply_country = "";
replyData.reply_myCheck = "";

replyData.onLoad = handleReply;


// Submit the order data
formData.sendAndLoad(submitURL, replyData, "post");


You are initializing the replyData function before the data has been returned. Merely switch the order and that portion as such:



replyData = new LoadVars();

// Submit the order data
formData.sendAndLoad(submitURL, replyData, "post");

replyData.onLoad = handleReply;


function handleReply(success) {
if(success == true) {

// Initialize reply variable.

replyData.reply_texte = "";
replyData.reply_name = "";
replyData.reply_salon = "";
replyData.reply_phone = "";
replyData.reply_email = "";
replyData.reply_address = "";
replyData.reply_city = "";
replyData.reply_statecounty = "";
replyData.reply_zip = "";
replyData.reply_country = "";
replyData.reply_myCheck = "";

gotoAndStop ("result");

result.text+= "NAME: "+name;
result.text+= "\nSALON: "+salon;
result.text+= "\nPHONE: "+phone;
result.text+= "\nEMAIL: "+email;
result.text+= "\nADDRESS: "+address;
result.text+= "\nCITY: "+city;
result.text+= "\nSTATE / COUNTY: "+statecounty;
result.text+= "\nZIP CODE: "+zip;
result.text+= "\nCOUNTRY: "+country;
result.text+= "\n" +checke;
result.text+= "\nCOMMENTS / QUESTIONS:\n"+texte;
} else {
gotoAndStop ("error");
result.text = "There was a problem submitting your information.\nPlease try again later.";
}
}


now i didnt really look at anything else, but your order was the biggest problem - you can't define variables using reply data that hasn't been requested yet - ie. putting the reply variable definitions and the onLoad statement before the sendAndLoad function.

kay2464
June 28th, 2005, 12:09 PM
Prstudio - Thanks so much for the advice! I am able to at least receive the email now, but I also changed the AS page around like you said. (I'm very new at this so I really appreciate the explanations.)


The two problems I have now are, first of all, I couldn't get it to work with placing the
replyData = new LoadVars(); before the sendAndLoad statement, so I have this right now (below). Is that incorrect?



// Submit the information
formData.sendAndLoad(submitURL, replyData, "post");
}

replyData = new LoadVars();
replyData.onLoad = handleReply;

function handleReply(success) {
if(success == true) {

...and secondly, the email is coming in with only the field names and not the actual user input... as if the variables are being wiped somehow in flash. Do I still have something set up incorrectly in the AS?

prstudio
June 28th, 2005, 01:45 PM
on mine it usually worked when i put it before ha! but if it works it works...

i took another look at the code (im awake now ha) and this part right here:
// Submit button function
function onSubmit() {
formData = new LoadVars();
formData.texte = "";
formData.name = "";
formData.salon = "";
formData.phone = "";
formData.email = "";
formData.address = "";
formData.city = "";
formData.satecounty = "";
formData.zip = "";
formData.country = "";
formData.myCheck = "";


replyData = new LoadVars();

// Initialize reply variable.
replyData.reply_texte = "";
replyData.reply_name = "";
replyData.reply_salon = "";
replyData.reply_phone = "";
replyData.reply_email = "";
replyData.reply_address = "";
replyData.reply_city = "";
replyData.reply_statecounty = "";
replyData.reply_zip = "";
replyData.reply_country = "";
replyData.reply_myCheck = "";


^that's setting all your fields to nothing.

if you have a textbox in the form and you give it instance name "FirstName"
to declare it to send you have to do something like:

mysendvars.FirstNameSent = FirstName.text;

then to load back information your ASP program has to be sending information back to flash - usually in the form of

"&reply_name=whatever"

then your reply variable that loaded everything the mail thing processed
is then dumped into variables or used directly to fill textboxes...

in yours you set all the reply data to ""; or nothing

hope this steers you - you're close to getting it working right - keep toying with it :)

kay2464
June 28th, 2005, 03:25 PM
Thanks again Prstudio. I follow what you're saying, except for this part:

if you have a textbox in the form and you give it instance name "FirstName"
to declare it to send you have to do something like:
mysendvars.FirstNameSent = FirstName.text;


Is it the "formData" variables that need to change?
e.g. formData.name = ""; to formData.nameSent = name.text;

kay2464
June 28th, 2005, 04:57 PM
Got it!
That was the ticket... I changed:
formData.name = "";
to this:
formData.name = name_f.text;

Thanks a million Prstudio! What a life saver!

(I Don't suppose you can offer advice on making the email field a "required field"?)

prstudio
June 28th, 2005, 07:16 PM
glad its working -

you can use an if statement inside of your submit function that checks to see if the contents of that field are empty:


if (formData.email != "";) {

//continue your submission process

}

else

{

//do something else like gotoAndPlay to
//the frame with the form - or have it
//display a message that says -
//email is required etc.
//message might be the best route

}

AFTERBURNER
May 20th, 2006, 11:11 PM
I'm having a problem with .asp as well...

I'm trying to make a .asp e-mail form just like this one in flash: http://dropstars.com/wheels/_swf/contact.swf

I got the flash part ok, but I want to know what the SendMail.asp code would be to make this work?

Thanks

THE AFTER BURNER:red: