Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send a web page as an attachment

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
Does anyone know how to programatically send a web page as an attachment with an email?

I have a report that is dynamically created and populates a webform page. I'd like to have it so that after the user runs the report and likes the results, he/she can click a button or a link and send it as an attachment to a given recipient.

The email part is easy, I'd just like to be able to create an HTML file that I can attach to or embed in an email.

Thanks.
 
You can use Page.RenderControl and save the results out to a HTML file that you could then email. For example:


Or you could save the output into a string and send it as part of the email body:


--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Another way of getting html content of any webpage is
Public Function GetPageContent(ByVal Url As String) As String
GetPageContent = ""
Try
Dim wreq As WebRequest
Dim wres As WebResponse
Dim sr As System.IO.StreamReader
Dim content As String

wreq = HttpWebRequest.Create(Url)
wres = wreq.GetResponse()
sr = New StreamReader(wres.GetResponseStream())
content = sr.ReadToEnd()
sr.Close()
GetPageContent = content

Catch
End Try

End Function
 
I believe this is possible with the CDO object. Look up references about using this object and that should help. There is a property that allows you to send a Web Page or a message within an email.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top