Thank you, George.
I need a little different, I guess. I just want to display my company name
at the bottom of the e-mail body as a hyperlink, just like here:
www.mycompanyname.com , so the person could click on it and get to my site.
It should be a simple task, I've just never done this before.
Peter
George said:
Not sure if this is what you're looking for, but this is how I build and send an e-mail message to
myself. Maybe it will give you some ideas.
Private Sub sendMail(ByVal msgTxt As String)
Dim msg As MailMessage = New MailMessage()
SmtpMail.SmtpServer = "xxxx.xxxx.com"
msg.Body = msgTxt
msg.From = "(e-mail address removed)"
msg.To = "(e-mail address removed)"
msg.Subject = "Some Subject!"
Try
SmtpMail.Send(msg)
Catch
End Try
End Sub
Private Sub SomeOtherSub()
Dim userAgent As String
Dim referringPage As String
If Not Request.UserAgent Is Nothing Then
userAgent = Request.UserAgent
Else
userAgent = "No user agent available!"
End If
'This is how I get a URL to string
If Not Request.UrlReferrer Is Nothing Then
referringPage = Request.UrlReferrer.ToString()
Else
referringPage = "Direct access by bookmark, local-based e-mail link, etc."
End If
Dim msgTxt As String = vbCrLf & _
"Browser Name: " & Request.Browser.Browser & vbCrLf & _
"Browser Type: " & Request.Browser.Type & vbCrLf & _
"Browser Version: " & Request.Browser.Version & vbCrLf & _
"Browser Platform: " & Request.Browser.Platform & vbCrLf & _
"Accepts Cookies: " & Request.Browser.Cookies & vbCrLf & _
"User Agent: " & userAgent & vbCrLf & _
"User Host Address: " & Request.UserHostAddress.ToString & vbCrLf & _
"User Host Name: " & Request.UserHostName & vbCrLf & _
"Referring URL: " & referringPage
If Not Request.Cookies("userInfo") Is Nothing Then
msgTxt = msgTxt & vbCrLf & vbCrLf & _
"This Visit: " & Request.Cookies("userInfo")("thisVisit") & vbCrLf & _
"Last Visit: " &
Request.Cookies("userInfo")("lastVisit") & vbCrLf & _
Request.Cookies("userInfo")("numVisits") & vbCrLf
End If
sendMail(msgTxt)
End Sub
I use the Try\Catch\End Try just in case the mail server is down. If it is, I just pass on getting
that particular message because I can live without it. So I don't really need to trap that error, I
just don't want my app to crash. User agent and URL Referrer will crash my app, too, so that is why
I'm checking them first. Maybe some of the others will, too, but not sure.
Hope that helped a little. I'm just learning this stuff, so there is
probably a better way to do it.