Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.net Email a link

Posted on 2014-01-20
4
Medium Priority
?
433 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:Murray Brown
  • 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:Murray Brown
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 2000 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:Murray Brown
ID: 39794918
Thanks very much
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

877 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