how can i Embed images in the Email Web Page

Discussion in 'ASP.NET / ASP.NET Core' started by wisemx, Mar 12, 2008.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. iam trying to send web page as email but i do not know how to embed my images inside that page
    my code is :

    Function sendemail(ByVal to1, ByVal pass)
    Try
    Dim mail As New MailMessage
    mail.To = "[email protected]"
    mail.From = "[email protected]"
    mail.Subject = "this is a test email."
    Dim url As String = "http://www.tayeen.com/index.aspx"
    mail.Body = HttpContent(url)
    mail.BodyFormat = MailFormat.Html
    mail.UrlContentBase = url
    ' mail.Body = "Some text goes here"
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]") 'set your username here
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456") 'set your password here
    SmtpMail.SmtpServer = "216.177.71.9"
    SmtpMail.SmtpServer.Insert(0, "216.177.71.9") 'your real server goes here
    SmtpMail.Send(mail)
    Return "Done"
    Catch ex As Exception
    Return ex.Message
    End Try
    End Function
     
  2. You can do something as follows:

    Private Function readHtmlPage(ByVal url As String) As String
    Dim result As String
    Dim objResponse As WebResponse
    Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url)
    objResponse = objRequest.GetResponse()
    Using sr As New StreamReader(objResponse.GetResponseStream())
    result = sr.ReadToEnd()
    ' Close and clean up the StreamReader
    sr.Close()
    End Using
    Return result
    End Function

    and use it as follows:

    Function sendemail(ByVal to1, ByVal pass)
    Try
    Dim message As String=readHtmlPage('http://www.tayeen.com/index.aspx')
    Dim mail As New MailMessage
    mail.To = '[email protected]'
    mail.From = '[email protected]'
    mail.Subject = 'this is a test email.'
    mail.Body = message
    mail.BodyFormat = MailFormat.Html
    mail.UrlContentBase = url
    ' mail.Body = 'Some text goes here'
    mail.Fields.Add('http://schemas.microsoft.com/cdo/configuration/smtpauthenticate', '1') 'basic authentication
    mail.Fields.Add('http://schemas.microsoft.com/cdo/configuration/sendusername', '[email protected]') 'set your username here
    mail.Fields.Add('http://schemas.microsoft.com/cdo/configuration/sendpassword', '123456') 'set your password here
    SmtpMail.SmtpServer = '216.177.71.9'
    SmtpMail.SmtpServer.Insert(0, '216.177.71.9') 'your real server goes here
    SmtpMail.Send(mail)
    Return 'Done'
    Catch ex As Exception
    Return ex.Message
    End Try
    End Function

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page