E-mail content of a webpage as html-mail





1
Date Submitted Thu. Apr. 30th, 2009 7:16 AM
Revision 1 of 1
Beginner johnyM
Tags Email | VB.NET
Comments 0 comments
Simple code to get the html of a webpage and send is as a html email msg.

Imports system
Imports System.web.mail
<script language="VB" runat="server">

    Sub sendmail()
        Dim mail As New MailMessage()
        Dim url As String = "http://www.some-url.com"
        mail.From = "your adres"
        mail.Subject = "Subject of the mail"
        mail.BodyFormat = MailFormat.Html
        mail.Body = HttpContent(url)
        SmtpMail.SmtpServer = "your smtp server adres"
        mail.To = "destination email adres"
        SmtpMail.Send(mail)
    End Sub
    Private Function HttpContent(ByVal url As String) As String
        Dim objWebClient As New System.Net.WebClient()
        Dim objUTF8 As New UTF8Encoding()
        Dim result As String = objUTF8.GetString(objWebClient.DownloadData(url))
        Return result
    End Function
 

Johny Meyssen

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Scripter elsevero

Votes Down