ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 7th, 2003, 03:58 PM
tknman0700 tknman0700 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 tknman0700 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old October 7th, 2003, 04:20 PM
xsoftdev xsoftdev is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Los Angeles, CA
Posts: 64 xsoftdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 7 sec
Reputation Power: 5
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
%>

Reply With Quote
  #3  
Old October 7th, 2003, 04:29 PM
tknman0700 tknman0700 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 tknman0700 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old October 7th, 2003, 08:27 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 6 m 22 sec
Reputation Power: 76
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.

Reply With Quote
  #5  
Old October 7th, 2003, 08:29 PM
tknman0700 tknman0700 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 tknman0700 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old October 7th, 2003, 08:54 PM
gurrutello gurrutello is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Spain
Posts: 15 gurrutello User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #7  
Old October 7th, 2003, 08:55 PM
tknman0700 tknman0700 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 tknman0700 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Right... we are talking about generating a file.. this is what I dont know how to do.. generate the file..

Thanks

Reply With Quote
  #8  
Old October 7th, 2003, 09:10 PM
gurrutello gurrutello is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Spain
Posts: 15 gurrutello User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #9  
Old October 7th, 2003, 09:54 PM
tknman0700 tknman0700 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 tknman0700 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.~!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How To Email ASP Page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway