Email AND File Appends

D

dmiller23462

I would like to append to a file, AS WELL AS, send an email via
ASP....I have some sample code from ASP101.com and am planning on
modifying it to my uses but I don't know where exactly I should place
it....Should I begin a whole new set of ASP commands or should I
incorporate it into the current ASP that specifies an email being
sent?

EMAIL BEING SENT
***
<%
Mode = request.form("mode")
From = request.form("from")
Ext = request.form("ext")
Subject = request.form("subject")
Body = request.form("body")

if mode = "Send" then

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "gwfs1" ' Specify a valid SMTP server
Mail.From = "(e-mail address removed)" ' Specify sender's address
Mail.FromName = "Dave Miller - Test Email" ' Specify sender's name

if subject = "" then
Mail.Subject = "Test Email"
else
Mail.Subject = subject
end if

Mail.AddAddress "dmiller"
Mail.AddReplyTo "(e-mail address removed)"

Mail.Body = body & vbcrlf & vbcrlf &
request.servervariables("REMOTE_ADDR")

On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If

End if
%>

SAMPLE CODE TO APPEND TO A FILE
***
<%
' Declare variables for the File System Object and the File to be
accessed.
Dim objFSO, objTextFile

' Create an instance of the the File System Object and assign it to
objFSO.
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Open the file
'Set objTextFile = objFSO.OpenTextFile("C:\InetPub\PR86027\samples\textfile.txt")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath("textfile.txt"))

Do While Not objTextFile.AtEndOfStream
Response.Write objTextFile.ReadLine & "<BR>" & vbCrLf
Loop

' Close the file.
objTextFile.Close

' Release reference to the text file.
Set objTextFile = Nothing

' Release reference to the File System Object.
Set objFSO = Nothing
%>
 
M

Me Padre

Using Persits ASP Email... it is way easier than you are
doing... if you are using the premium version

Try:

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "gwfs1"
Mail.From = "(e-mail address removed)"
Mail.FromName = "Dave Miller - Test Email"
if subject = "" then
Mail.Subject = "Test Email"
else
Mail.Subject = subject
end if
Mail.AddAddress "dmiller"
Mail.AddReplyTo "(e-mail address removed)"
Mail.Body = body & vbcrlf & vbcrlf &
request.servervariables("REMOTE_ADDR")

' -------------------------------------

' ASSUMES THE PREMIUM VERSION OF ASPEMAIL

strFile = "C:\path\to\file\fileToAppend.txt"
mail.appendBodyFromFile strFile, true

' Note the true appends it to the Body
' If it were false it would append it to
' the AltBody (for multipart messages)

' -------------------------------------

On Error Resume Next

Mail.Send
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top