Reading data from textarea line by line - need to loop
Posted on 2007-11-13
I'm writing a script in VBScript for a classic ASP application (NOT ASP.NET), and I hope someone here has succeeded in this.
What I'm doing involves a form which posts to a script which will take the data and compose/send an email using CDONTS (it's on a Win2K server, IIS 5.0). The idea is to be able to paste a list of email addresses separated by \n into the textarea. When the form is submitted, the handling script uses a Do While... Loop to extract the first line (email address) from the textarea, compose and send an email message, and then loop to the second line, compose and send a message, loop, etc. until it reaches the end.
I have this successfully working using a text file on the server containing the email addresses using the FileScriptingObject in ASP (opening the file for reading using OpenAsTextStream) instead of the textarea method, and it works fine. There's nothing wrong with the script itself at this point, other that that I can't figure out how to extract the contents of the textarea one line at a time so that I can use the Do While... Loop.
I know I could make it a two step process by writing the contents of the textarea to a text file on the server, and then using the OpenAsTextStream method to call it back into the script. It just seems like I should be able to do this without having to write to a file.
Any ideas? I'm probably missing something obvious, but 20 pages of a Google search didn't give me anything.