Solved

ASP.net Email a link

Posted on 2014-01-20
4
415 Views
Last Modified: 2014-01-20
Hi

 I am using the following code to email a link. At the moment it comes up as just text
How do I alter the code to make the link appear as a link in my email body



   Sub oSendEmail(ByVal oActivationCode As String)
        Try
            'www.webexcel.co.za/Default.aspx?activation_code=asdfd123dfa&email=m@b

            Dim oEmail As String = Me.txtEmail.Text
            Dim oMessage As String = "Please click on the following link to verify your email address:"

            Dim oLink As String = _
                "www.webexcel.co.za/Email_Verification.aspx?activation_code=" & oActivationCode & "&email=" & oEmail
            Dim sBody As String = oLink & "<br />" & oLink

            oSendMailMessage("info@online-excel.com", oEmail, "info@online-excel.com", "", "Please verify your email", sBody)
        Catch ex As Exception
            Me.lblError.Text = "Problem sending verification email: " & ex.Message
        End Try
    End Sub

   Public Sub oSendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
        Try

            ' Instantiate a new instance of MailMessage
            Dim mMailMessage As New MailMessage()

            ' Set the sender address of the mail message
            mMailMessage.From = New MailAddress(from)
            ' Set the recepient address of the mail message
            mMailMessage.To.Add(New MailAddress(recepient))

            ' Check if the bcc value is nothing or an empty string
            If Not bcc Is Nothing And bcc <> String.Empty Then
                ' Set the Bcc address of the mail message
                mMailMessage.Bcc.Add(New MailAddress(bcc))
            End If

            ' Check if the cc value is nothing or an empty value
            If Not cc Is Nothing And cc <> String.Empty Then
                ' Set the CC address of the mail message
                mMailMessage.CC.Add(New MailAddress(cc))
            End If

            ' Set the subject of the mail message
            mMailMessage.Subject = subject
            ' Set the body of the mail message
            mMailMessage.Body = body

            ' Set the format of the mail message body as HTML
            mMailMessage.IsBodyHtml = True
            ' Set the priority of the mail message to normal
            mMailMessage.Priority = MailPriority.Normal

            ' Instantiate a new instance of SmtpClient
            Dim mSmtpClient As New SmtpClient()
            ' Send the mail message
            mSmtpClient.Send(mMailMessage)
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub
0
Comment
Question by:murbro
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 39794741
1.  Try putting "http://" as part of the link
2.  Try writing a complete tag, e.g. <a href="http://www ...">whatever text</a>
0
 

Author Comment

by:murbro
ID: 39794862
Thanks
How would the following code look
    Dim oLink As String = _
                "www.webexcel.co.za/Email_Verification.aspx?activation_code=" & oActivationCode & "&email=" & oEmail

I'm not sure to have the tag inside or outside the quotes
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 39794897
Dim oLink As String = _
                "<a href=""http://www.webexcel.co.za/Email_Verification.aspx?activation_code=" & oActivationCode & "&email=" & oEmail & """>Text</a>"

You escape " by doing two of them -- "" -- hence the double and triple quotations.
0
 

Author Closing Comment

by:murbro
ID: 39794918
Thanks very much
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp day pilot 3 19
Problem to refer to value 8 49
asp.net mvc5 6 17
VB.net capture  result of a SQL query in variables 3 10
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question