|
-
August 21st, 2007, 01:21 PM
#1
Hyperlink in text string
Hello,
Is there a way to include a hyperlink inside a string? I am using SMTP to send a verification email, and I would like to inlcude a hyperlink to the website login, as well as a link to the admin email. I was able to get this working, but the entire path show up for the hyperlink, and "mailto:" is including at the beginning of the email link. For formatting purposes I would like this to be setup similar to a standard A HREF hyperlink tag. Here is the code i am working with. Thanks for any help on this!
Code:
Private Sub SendEmailNotification(ByVal Message As String, ByVal Question As String, ByVal OptionName As String, ByVal Rating As String)
Dim mailMsg As New MailMessage("[email protected]", "[email protected]")
With mailMsg
.Subject = "Moderation Required!"
.Body = UserInfo.DisplayName & " has modified comments related to """ & Question & """. Please Log into ""MyBold"" to review." & vbCrLf & vbCrLf _
& " User: " & UserInfo.DisplayName & vbCrLf _
& " Question: " & Question & vbCrLf _
& "Option Name: " & OptionName & vbCrLf _
& " Rating: " & Rating & vbCrLf _
& " Comment: " & Message & vbCrLf _
& " Date/Time: " & Now() & vbCrLf & vbCrLf _
& "Login to http://www.mywebsite.com/bt2/Home/tabid/36/ctl/Login/Default.aspx?returnurl=%2fbt2%2fHome%2ftabid%2f36%2fDefault.aspx to moderate user requests." & vbCrLf _"
& "Admin:" & vbCrLf _
& "mailto:" & mailMsg.From.Address
End With
Try
Dim emailClient As New SmtpClient("dom-02.boldgroup.int", 25)
emailClient.Send(mailMsg)
Catch exp As Exception
lblUserMessage.Text = exp.ToString()
End Try
End Sub
-
August 21st, 2007, 10:15 PM
#2
Re: Hyperlink in text string
Your MailMessage needs to be in HTML format first, then you just make the body a string containing HTML code, including an HREF tag.
-
August 21st, 2007, 10:27 PM
#3
Re: Hyperlink in text string
here is a sample code
Code:
Dim m As New System.Web.Mail.MailMessage
Dim sm As System.Web.Mail.SmtpMail
m.BodyFormat = Web.Mail.MailFormat.Html
m.To = "[email protected]"
m.From = "[email protected]"
m.Subject = "test"
m.Body = "<html><body>" & _
"<p />" & _
"Please click <a href=""http://domain.com/mysite"">here</a> to login." & _
"<p />" & _
"Please click <a href=""mailto:[email protected]"">here</a> to mail me." & _
"</body></html>"
sm.SmtpServer = "<your mail server here>"
sm.Send(m)
Busy 
-
August 22nd, 2007, 01:55 AM
#4
Re: Hyperlink in text string
 Originally Posted by Thread1
here is a sample code
Code:
Dim m As New System.Web.Mail.MailMessage
Dim sm As System.Web.Mail.SmtpMail
m.BodyFormat = Web.Mail.MailFormat.Html
m.To = "[email protected]"
m.From = "[email protected]"
m.Subject = "test"
m.Body = "<html><body>" & _
"<p />" & _
"Please click <a href=""http://domain.com/mysite"">here</a> to login." & _
"<p />" & _
"Please click <a href=""mailto:[email protected]"">here</a> to mail me." & _
"</body></html>"
sm.SmtpServer = "<your mail server here>"
sm.Send(m)
The OP is using System.Net.Mail (.Net 2.0+), not System.Web.Mail (.NET 1.x).
-
August 22nd, 2007, 02:29 AM
#5
Re: Hyperlink in text string
^ nice catch
Busy 
-
August 22nd, 2007, 09:27 AM
#6
Re: Hyperlink in text string
Many Thanks! Its working now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|