|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Email Body Text - Help!
Ok, firstly thanks to everyone who looks at this thread and posts, as I'm finding solving my current problem not only tricky, but extremely irritating.
Basically, I am tweaking the website for the company where I work and am trying to grab information from a form which potential customers fill out, then email those fields to our email address. The form has been written, and works fine. I've also written the script to grab the info and email it, which runs fine... ...my problem lies with tweaking the body text to include headers which will help those who receive the emails ascertain to which field the information that has been mailed is taken (currently the form information is simply listed in the email, with a line break between each section. So, for example, the first line shows whatever the customer filled out in the 'Name' field on the form, but nothing to indicate to the email reader that that is the name field). Incidentally, please disregard the strange field names. They are all correct, and do work, they are just thus named due to me being lazy and simply copy/pasting new fields in, rather than naming each one. My script, which grabs from the form, is as follows. This script works perfectly, I just don't know how to add indications into the body text as to which bit of information belongs to which field. <% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> <% Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component. Mail.FromName = Request.Form ("email") Mail.FromAddress = Request.Form ("email3") Mail.RemoteHost = "mrvnet.kundenserver.de" ' The mail server you have to use with Asp Mail Mail.AddRecipient "US", "OUREMAIL@OURDOMAIN.com" Mail.Subject = "Customer Request" Mail.BodyText = Request.Form("email") & vbcrlf & Request.Form("email2") & vbcrlf & Request.Form("email4") & vbcrlf & Request.Form("email5") & vbcrlf & Request.Form("email6") & vbcrlf & Request.Form("email7") & vbcrlf & Request.Form("email72") & vbcrlf & Request.Form("email73") & vbcrlf & Request.Form("email732") & vbcrlf & Request.Form("email7322") & vbcrlf & Request.Form("email733") & vbcrlf & Request.Form("info") if Mail.SendMail then Response.Redirect("thankyou.asp") else Response.Write "Mail send failure. Error was " & Mail.Response end if Set Mail = Nothing %> </p> <p> </p> </body> </html> |
|
#2
|
|||
|
|||
|
Hi,
Maybe I misunderstand your problem completely, but can't you just do the following: - Code:
Mail.BodyText = _
"Kunde = " & Request.Form("email") & vbcrlf & _
"Plz = " & Request.Form("email2") & vbcrlf & _
"Ort = " & Request.Form("email4")
and so on et cet era und so weiter I think you could lookup the tags from the fields to make the script less hardcoded, but I'm not really in ASP/HTML/VB scripting, so you need advice from someone more knowledgeable than me. If that's not the case, what are you trying to achieve?? Regards, Michiel |
|
#3
|
|||
|
|||
|
Firstly, mvagh2, thank you very much. My script to grab and email the form details now works!
I have one more question, though: some of the emails from the form are coming through without a line break between certain fields. Now the obvious answer is that the line break code doesn't exist for that line, but, er, it does. My code has "<whatever the field is called> = " & Request.Form("<the field's ID>") & vbcrlf & _ for every single form box. What I don't understand is why some, not all, of the subsequent emails have the last four of five fields as being listed on one long line, instead of in seperate lines. |
|
#4
|
|||
|
|||
|
Hi,
1. You're welcome. 2. I don't know. However, personally when I encounter such an error, I double/triple/quadruple-check the spelling of vbcrlf. I misspell it all the time... But then again, not all emails suffer from the problem, as I understand - so that should rule out a typo. Can't help you any further at this stage I'm afraid. Good luck. Michiel |
|
#5
|
|||
|
|||
|
If your mail is in html you might need to add <br />
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#6
|
|||
|
|||
|
I've checked my VB scripting and everything is fine. All the vbcrlf instances are correctly spelt, and, unfortunately, the script and page aren't HTML, so that rules out using a standard HTML break command...
...however, I've done a few tests and noticed something interesting: I essentially filled my own form in 6 times, and each time put an extremely lengthy piece of information in a different field each time. When the emails came through to my inbox, I noticed that each field was on its own seperate line, as it should be, but only up to the field that contained the long line of information. Everything after that suddenly lost all its line breaks and became one long string. So, it looks like there is a limit in ASP mail VB scripting to the total length of characters one can include on a form if you still want the line break to occur. I don't quite understand why this should be, but my tests have pretty conclusively proven it to be true. So, um, any ideas how I can stop this? |
|
#7
|
|||
|
|||
|
Hi,
No - not really. Maybe run a testscript generating a body with one char less each time it runs. That way determine the threshold for this whacky behaviour and have the page truncate the message based on that amount (or warn the user and not pass the message before he/she truncates it him-/herself). Not much of a help actually. Regards, Michiel |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Email Body Text - Help! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|