title: how can i append form data to a csv file in asp and email users at the same time?
body: <p>I have a referral form that a user can refer friends for membership. The form action has to point to an asp file. (I started in php and got it working on a different server, but the server it needs to be on must be asp). I have searched and searched and I am having some issues. (I am an asp newbie)</p>
  
  <ol>
  <li><p>The form must send an email to the users. I got this working in an asp file here(<strong>email.asp</strong>):</p>
  
  <pre><code>&lt;%
  Dim senderName, senderEmail, senderMessage
  Dim name1, name2, name3, name4, name5, name6, name7, name8, name9, name10
  Dim email1, email2, email3, email4, email5, email6, email7, email8, email9, email10
  senderName = Request.Form("senderName")
  senderEmail = Request.Form("senderEmail")
  senderMessage = Request.Form("senderMessage")
  name1 = Request.Form("name1")
  name2 = Request.Form("name2")
  name3 = Request.Form("name3")
  name4 = Request.Form("name4")
  name5 = Request.Form("name5")
  name6 = Request.Form("name6")
  name7 = Request.Form("name7")
  name8 = Request.Form("name8")
  name9 = Request.Form("name9")
  name10 = Request.Form("name10")
  email1 = Request.Form("email1")
  email2 = Request.Form("email2")
  email3 = Request.Form("email3")
  email4 = Request.Form("email4")
  email5 = Request.Form("email5")
  email6 = Request.Form("email6")
  email7 = Request.Form("email7")
  email8 = Request.Form("email8")
  email9 = Request.Form("email9")
  email10 = Request.Form("email10")   
  
  'Sends an email
  Dim mail
  Set mail = Server.CreateObject("CDO.Message")
  'for testing i am only sending to the first email
  mail.To = email1
  mail.From = senderEmail
  mail.Subject = "Join Dallas Cowboys True Blue Fan Club with me!"
  mail.TextBody = "Join Dallas Cowboys True Blue Fan Club with me!"
  mail.Send()
  Response.Write("Mail Sent!")
  'Destroy the mail object!
  Set mail = nothing
  %&gt;
  </code></pre></li>
  <li><p>Finally, I have a working aspx file (<strong>append.aspx</strong>) that will append the form data to a csv file. The real issue i have is combining both files into just 1 working file. </p>
  
  <pre><code>&lt;%@ Import Namespace="System.IO" %&gt;
  &lt;script type="text/javascript"&gt;
  window.onload = window.close();
  &lt;/script&gt;
  &lt;script language="vb" runat="server"&gt;
  sub Page_Load(sender as Object, e as EventArgs)
  'Open a file for writing
  Dim FILENAME as String = Server.MapPath("Output.csv")
  
  Dim senderName, senderEmail, senderMessage
  Dim name1, name2, name3, name4, name5, name6, name7, name8, name9, name10
  Dim email1, email2, email3, email4, email5, email6, email7, email8, email9, email10
  senderName = Request.Form("senderName")
  senderEmail = Request.Form("senderEmail")
  senderMessage = Request.Form("senderMessage")
  name1 = Request.Form("name1")
  name2 = Request.Form("name2")
  name3 = Request.Form("name3")
  name4 = Request.Form("name4")
  name5 = Request.Form("name5")
  name6 = Request.Form("name6")
  name7 = Request.Form("name7")
  name8 = Request.Form("name8")
  name9 = Request.Form("name9")
  name10 = Request.Form("name10")
  email1 = Request.Form("email1")
  email2 = Request.Form("email2")
  email3 = Request.Form("email3")
  email4 = Request.Form("email4")
  email5 = Request.Form("email5")
  email6 = Request.Form("email6")
  email7 = Request.Form("email7")
  email8 = Request.Form("email8")
  email9 = Request.Form("email9")
  email10 = Request.Form("email10")   
  
  'Get a StreamWriter class that can be used to write to the file
  Dim objStreamWriter as StreamWriter
  objStreamWriter = File.AppEndText(FILENAME)
  
  'AppEnd the the End of the string, "A user viewed this demo at: "
  'followed by the current date and time
  objStreamWriter.WriteLine(sEnderName &amp; "," &amp; sEnderEmail &amp; "," &amp; name1 &amp; "," &amp; email1 &amp; "," &amp; senderMessage &amp; "," &amp; DateTime.Now.ToString())
  If name2 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name2 &amp; "," &amp; email2)
  End If
  If name3 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name3 &amp; "," &amp; email3)
  End If
  If name4 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name4 &amp; "," &amp; email4)
  End If
  If name5 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name5 &amp; "," &amp; email5)
  End If
  If name6 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name6 &amp; "," &amp; email6)
  End If
  If name7 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name7 &amp; "," &amp; email7)
  End If
  If name8 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name8 &amp; "," &amp; email8)
  End If
  If name9 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name9 &amp; "," &amp; email9)
  End If
  If name10 &lt;&gt; "" then
  objStreamWriter.WriteLine("," &amp; "," &amp; name10 &amp; "," &amp; email10)
  End If
  'Close the stream
  objStreamWriter.Close()
  End sub
  &lt;/script&gt;
  </code></pre></li>
  </ol>