Solved

ASP.net Email a link

Posted on 2014-01-20
4
413 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now