| | |
need help how to produce a txt file after email being sent in ASP
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2006
Posts: 19
Reputation:
Solved Threads: 0
I have done the back-end code in the ASP,
I was wondering if there's a way to produce a text file on a server, after form has been submitted by user. I am also putting a script to put via email, but want to save it as a text file for each message sent for backup purposes. Or if some of the people want to go back and track the messages
Here is the ASP Code:
<%@ Language=VBScript %>
<%
Option Explicit
%>
<%
' -----------------------------------------------------
' CDONTS Email send script
' © http://www.designplace.org/
' Comments must remain intact for re-use of this code
' -----------------------------------------------------
dim strName, strEmailOne, strEmailTwo, strMessage, optSuggestions, strEmailTo
strName = Request.Form("name") ' 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
optSuggestions = Request.Form("suggestions").Item ' drop down list selection
' -- 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 optSuggestions
Case "Web Enhancements"
strEmailTo = "kdemas@avanquestusa.com"
Case "Application Enhancements"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "New Product Suggestions"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Workplace Suggestions"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Employee Recognition"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Cultural Events"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Other"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case Else
strEmailTo = "jadem@avanquestusa.com;syoung@avanquestusa.com;feedback@avanquestusa.com"
End Select
' -- end determine correct send to address based on suggestion type --
' -- begin email send process --
dim objMail
Set objMail = CreateObject("CDONTS.NewMail")
' -- email variables --
objMail.To = Trim(strEmailTo)
objMail.From = Trim("feedback@avanquestusa.com")
objMail.Subject = "Suggestion box for Avanquest North America"
objMail.BodyFormat = "0" ' HTML format
objMail.Body = "Here are some suggestions, comments and concerns for Avanquest North America:" & vbCrLf _
& vbCrLf _
& "Type of Suggestions/Comments: " & Trim(optSuggestions) & vbCrLf _
& vbCrLf _
& "Message: " & Trim(strMessage)
' -- send the email --
objMail.Send
' -- clean up object
Set objMail = Nothing
' -- execute confirmation page
Response.Redirect "thankyou.asp"
%>
I was wondering if there's a way to produce a text file on a server, after form has been submitted by user. I am also putting a script to put via email, but want to save it as a text file for each message sent for backup purposes. Or if some of the people want to go back and track the messages
Here is the ASP Code:
<%@ Language=VBScript %>
<%
Option Explicit
%>
<%
' -----------------------------------------------------
' CDONTS Email send script
' © http://www.designplace.org/
' Comments must remain intact for re-use of this code
' -----------------------------------------------------
dim strName, strEmailOne, strEmailTwo, strMessage, optSuggestions, strEmailTo
strName = Request.Form("name") ' 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
optSuggestions = Request.Form("suggestions").Item ' drop down list selection
' -- 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 optSuggestions
Case "Web Enhancements"
strEmailTo = "kdemas@avanquestusa.com"
Case "Application Enhancements"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "New Product Suggestions"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Workplace Suggestions"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Employee Recognition"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Cultural Events"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case "Other"
strEmailTo = "jemalonzo2001@yahoo.com;jadem@avanquestusa.com"
Case Else
strEmailTo = "jadem@avanquestusa.com;syoung@avanquestusa.com;feedback@avanquestusa.com"
End Select
' -- end determine correct send to address based on suggestion type --
' -- begin email send process --
dim objMail
Set objMail = CreateObject("CDONTS.NewMail")
' -- email variables --
objMail.To = Trim(strEmailTo)
objMail.From = Trim("feedback@avanquestusa.com")
objMail.Subject = "Suggestion box for Avanquest North America"
objMail.BodyFormat = "0" ' HTML format
objMail.Body = "Here are some suggestions, comments and concerns for Avanquest North America:" & vbCrLf _
& vbCrLf _
& "Type of Suggestions/Comments: " & Trim(optSuggestions) & vbCrLf _
& vbCrLf _
& "Message: " & Trim(strMessage)
' -- send the email --
objMail.Send
' -- clean up object
Set objMail = Nothing
' -- execute confirmation page
Response.Redirect "thankyou.asp"
%>
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
To create and write a file pertaining to the email sent, use the following code:
This will create a text file with todays date followed by a unique key so there are no duplicates. It will write your entire email there. This is not very efficient in finding emails delt on a large basis. It will only spit out something like this in a folder: 1132007_KLJDLL.txt
Obviously you cannot tell what it is by just looking at it. Get creating, set a new name to it if you wish!
ASP Syntax (Toggle Plain Text)
Dim filename, fs, f, strRnd strRnd = FormatDateTime(Now(),2) & "_" strRnd = Replace(strRnd, "/", "") For intCounter = 1 To 6 intDecimal = Int((26 * Rnd) + 1) + 96 strRnd = strRnd & Chr(intDecimal) Next filename = strRnd & ".txt" Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.CreateTextFile(filename,true) f.write(objMail.Body) 'or set objmail.body to another variable and call it here. 'if you do call this variable or set it to another variable, 'you must do it before you end the objMail but after you 'set the objMail.Body. f.close Set f=nothing Set fs=nothing
Obviously you cannot tell what it is by just looking at it. Get creating, set a new name to it if you wish!
![]() |
Similar Threads
- Capturing data from txt file using JavaScript/HTML (JavaScript / DHTML / AJAX)
- Password Protection from a txt.file (HTML and CSS)
- how to display an attached image file in email (ASP)
- how to launch a txt file (VB.NET)
- reading txt file into array (C++)
- How can I read from a txt file? (C++)
- URGENT - Reading from txt file into a 2 dimension array (Java)
- uploading .txt file via phpmyadmin to Mysql (MySQL)
Other Threads in the ASP Forum
- Previous Thread: How to access DOM table objects in an iframe with VBScript
- Next Thread: help me please. i am making a login page..
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7






