Solved

ASP.net Email a link

Posted on 2014-01-20
4
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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:Murray Brown
ID: 39794918
Thanks very much
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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