Solved

ASP.net Email a link

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

16 Experts available now in Live!

Get 1:1 Help Now