Hi,

I'm kind of new on the field of ASP, I wanted to export the body of the email as a text file. Is there any way to create the data on a text file. Please provide some suggestions how to go about this problem.

Let me provide the send mail.asp code below

<%@ Language=VBScript %>

<%
Option Explicit
%>

<%
' -----------------------------------------------------
' CDONTS Email send script
' © http://www.designplace.org/
' Comments must remain intact for re-use of this code
' -----------------------------------------------------

dim strFName, strLName, strEmailOne, strEmailTwo, strMessage, optEducation, strEmailTo

strFName = Request.Form("fname") ' holds inputted name
strLName = Request.Form("lname") ' holds inputted name
'strEmailOne = Request.Form("emailOne") ' holds inputted email address
strEmailTwo = Request.Form("emailTwo") ' holds inputted email address
strMessage = Request.Form("message") ' holds inputted message
optEducation = Request.Form("educ_levels").Item ' drop down list selection of education levels each user primarily teaches

' -- check all fields for empty values --
' -- remove and add new as required --

'if strMessage = "" then
' Response.Redirect "suggestion_box.asp?action=err4"
'end if

' if strName = "" then
' Response.Redirect "suggestion_box.asp?action=err1"
' else if strEmailOne = "" then
' Response.Redirect "suggestion_box.asp?action=err2"
' else if strEmailTwo = "" then
'Response.Redirect "suggestion_box.asp?action=err3"
'else if strMessage = "" then
'Response.Redirect "suggestion_box.asp?action=err4"
'else if optSuggestions = "" then
'Response.Redirect "suggestion_box.asp?action=err5"
'end if
'end if
'end if
'end if
'end if

' -- start determine correct send to address based on suggestion type --

Select Case optEducation

Case "Preschool"
educ_levels = "Preschool"

Case "Elementary"
educ_levels = "Elementary Teachers and Staff"

Case "High School"
educ_levels= "High School Teachers and Staff"

Case "College"
educ_levels = "College Professors, Staff and Administrators"

Case "Child Development"
educ_levels = "Child Development Professionals"

Case "Special Education"
educ_levels = "Special Education Professionals"

Case "Counselors"
educ_levels = "Counselors"

Case "Parent or Guardian"
educ_levels = "Parent or Guardian"

Case Else
educ_levels = "Other"

End Select

' -- end determine correct send to address based on suggestion type --

' -- begin email send process --

dim objMail

Set objMail = Server.CreateObject("CDO.Message")
'Set objMail = CreateObject("CDONTS.NewMail")

' -- email variables --
objMail.From = Trim("feedback@avanquestusa.com")
objMail.To = Trim(strEmailTwo)
objMail.Subject = "Discount Code for Avanquest Educators Perks Program"
'objMail.BodyFormat = "0" ' HTML format
objMail.TextBody = "Hello" & Trim(strFName) & Trim(strLName) & vbCrLf _
& vbCrLf _
& "Thank you for signing up at AVQ Corporate. " & vbCrLf _
& vbCrLf _
& "Put text message here " & Trim(optSuggestions) & vbCrLf _
& vbCrLf _
& "You primarily teach at " & Trim(optEducation)

' -- send the email --
objMail.Send()

' -- clean up object
Set objMail = Nothing

' -- execute confirmation page
Response.Redirect "thankyou.asp"
%>

You can use the "Scripting.FilesystemObject" to create your file and write data to it.
<%
dim fs,fname,overwriteContents,unicode,ascii
overwriteContets=true;
unicode=true
ascii=Not Unicode

set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile( Server.Mappath("myLog.txt"),overwriteContents,ascii)
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.