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 = "xx**@xxxxx.com"
msg.To = "xx**@xxxx.net"
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 & _
"Total Visits: " & 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.
I've gotten a lot of answers in this NG, so thought I'd try to give back a little. ;-)
George
"Peter Afonin" <pv*@speakeasy.net> wrote in message news:eV**************@TK2MSFTNGP10.phx.gbl...
Hello,
I created an e-mail form pretty much as described in this article:
http://www.4guysfromrolla.com/webtech/080801-1.shtml. It works great, but I
cannot figure out one thing:
I need to insert a URL at the bottom of the message body. How would I do
this? If I insert just HTML - it displays HTML. I tried Response.Write
method, StringBuilder and HTMLTextWriter classes - no luck so far.
I would appreciate your advice on this.
Thank you,
--
Peter Afonin