Jump to content

Help...Need help with posting forms via email


biscut

Recommended Posts

Hi guysI have declared several variables in my asp script such as:Dim PostcodeDim Contact_Telephone_NoDim contact_email_addressCollected the values from the fields/variables from my form:Postcode = Trim(Request.Form("Postcode"))Contact_Telephone_No = Trim(Request.Form("Contact_Telephone_No"))contact_email_address = Trim(Request.Form("contact_email_address"))and am able to create an email that gets sent successfully when the values etc are submitted by use of:TextBody = TextBody & "Postcode: " & Postcode & VbCrLfTextBody = TextBody & "Contact_Telephone_No: " & Contact_Telephone_No & VbCrLfTextBody = TextBody & "contact_email_address: " & contact_email_address & VbCrLfHowever, my question is, if I have quite a few fields then how can I change the email that gets submitted to only send through results where someone has filled in a box on the form. The form I need to create will have quite a few fields on it (all optional) and I am only interested in seeing/receiving the results from boxes that have been filled in, rather than wading through loads of entries that are empty.Is this a case of using if/then/else statements ? If it is, could someone be kind enough to give me an example or point me to a site where I can see what coding I need ? I have had a look through the tutorials etc and cant see a reference to what I need...can anyone help me please ??Thank you very much for your timeRegardsDavidt

Link to comment
Share on other sites

Something like this?

TextBody = ""if Postcode <> "" then TextBody = TextBody & "Postcode: " & Postcode & VbCrLfif Contact_Telephone_No <> "" then TextBody = TextBody & "Contact_Telephone_No: " & Contact_Telephone_No & VbCrLf

If I've got "does not equal" incorrect (<>) I apologize, I don't know how to do that in VB.

Link to comment
Share on other sites

Thank you very much for your help...do I need to use the "else" statement somewhere or is just if/then sufficient ?
No problem. I think in this case, a series of if/thens will work for you since you only want something to happen if a certain condition is met - the else in this case is "do nothing".
Link to comment
Share on other sites

you are a genius, it works perfectly thank you SO much for your help...tell your boss you should be on 50,000 a year...unless you are already on more than that at the moment...You have saved me SO much hassle Thanks againRegardsDavidt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...