|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How To Email ASP Page
I am new to ASP and I am trying to do the following...
I have an ASP page that is essentially a report.. I need to give hte user a method to "Click Here" and email a pdf version of the page or possibly an html file... can this be done... rather how can this be done please? Thanks for your help. |
|
#2
|
|||
|
|||
|
Here is a method you could customize.
http://asp101.aspin.com/func/conten...6310&cob=asp101 <% dim done done = request.form("done") if done = "" then done = "No" %> <html> <head> <title>Tell a friend</title> </head> <body> <table border="1" cellspacing="0" cellpadding="0" bgcolor="#006599"> <TR> <TD> <form action="tellfriend.asp" method="post"> <B><font color="white">Tell a Friend</font><B>:<BR> <input type="text" name="email" size="20" maxlength="50"><BR> <input type="hidden" name="done" value="Yes"> <center><input type="submit" name="submit" value="Tell a friend"></center> </form> </TD> </TR> </Table> </body> </html> <% Else if request.form("done") = "Yes" then 'sets variables dim email, sendmail email = request.form("email") Set sendmail = Server.CreateObject("CDONTS.NewMail") 'put the webmaster address here sendmail.From = "webmaster@aspbasics.com" 'The mail is sent to the address entered in the previous page. sendmail.To = email 'Enter the subject of your mail here sendmail.Subject = "Check out this website" 'send a specific page or send a site url dim url 'url = Request.ServerVariables("HTTP_REFERER") url = "http://www.aspbasics.net" 'This is the content of thr message. sendmail.Body = "Site recommendation from a friend!" & _ vbCrlf & vbCrlf & "A friend has sent you this email and thought you would should check out this site." & _ vbCrlf & url & vbCrlf 'this sets mail priority.... 0=low 1=normal 2=high sendmail.Importance = 1 sendmail.Send 'Send the email! response.redirect Request.ServerVariables("HTTP_REFERER") 'Response.write ("Sent to ") & email End if End if %> |
|
#3
|
|||
|
|||
|
This is very good but unfortunatley the part I am having trouble with is how to generate the file to send with the email.. it is a privately generated page.. need to be able to send the entire page (self contained) to the recipient either as html doc or pdf.
|
|
#4
|
||||
|
||||
|
You could put all the html code and everything for the page into a variable, then use the file system object to write the variable into a blank html page, then attach that html page.
|
|
#5
|
|||
|
|||
|
So I would have the code for the page essentially doubled? This is an idea... I might check it out.. not sure exactly how to make it work other than copy the entire asp page and set a variable = to paste the text.
|
|
#6
|
|||
|
|||
|
hello
other way to doit is generating a .txt file with the asp code and send to your users like a attach file. Im using this way to send my users. |
|
#7
|
|||
|
|||
|
Right... we are talking about generating a file.. this is what I dont know how to do.. generate the file..
Thanks |
|
#8
|
|||
|
|||
|
ok the way i do is
create_txt.asp <% ' Your connection etc .... ' c:\testfile.txt must be a root path ' the text file name you acn get it from a request("...") ' then will be like Set f = fso.OpenTextFile("c:\"&request("filename")&"", ForWriting, True) Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True) f.Write rs("recordset") ' File was created response.redirect"send.asp?filename=testfile.txt&your_variables=email_etc..." %> send.asp ' now we send the email ' objMail.AttachFile("c:\testfile.txt") needs to be the root path on your server <% Option Explicit Dim objMail Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = request("email_from") objMail.Subject = "Title" objMail.AttachFile("c:\testfile.txt") objMail.To = request("mail_to") objMail.Body = "Body of message" objMail.Send Response.Write("The mail was sent") Set objMail = Nothing %> this is the way i use to create a text file and send by email using strings ( no forms ) but there are many more ways to do it. You must remember that to create the text file you need to have write permissions to your server, if not you have to create manually and send the one is already in your server. Sorry my poor english, im spanish. I hope it was helpfully to you bye |
|
#9
|
|||
|
|||
|
This is good... thank you for your help.. it is pointing me in the right direction now. I suppose what I will do is redirect all of the entire page to the html file.. then rediret the browser to that html file.. then I will have a link on that page (the opened html file) to email the document.
So essentially I will take the existing asp code and assign it to a variable.. there are quite a few lines... then I will write that variable to a html file.. then redirect the browser to that html file... will that work? THanks for your continued help with this... great board.~! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > How To Email ASP Page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|