|
Home > Archive > IIS ASP > May 2004 > Email AND File Appends
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Email AND File Appends
|
|
| dmiller23462 2004-05-30, 11:54 am |
| 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 = "dmiller@coach.com" ' 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 "dmiller@coach.com"
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
%>
| |
| Curt_C [MVP] 2004-05-30, 11:54 am |
| put it all in one page
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"dmiller23462" <dmiller23462@yahoo.com> wrote in message
news:591ac515.0405271251.2ba35d47@posting.google.com...
> 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 = "dmiller@coach.com" ' 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 "dmiller@coach.com"
>
> 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
> %>
|
|
|
|
|