Reputation: 1562
Dim x As String
x = "http://www.domain.com/aaa/test/default2.aspx?date=" & now.Text & "&tfname=" & p1fname.Text & "&tlname=" & p1lname.Text & "&comp=" & Request.QueryString("comp")
Dim objEmail As New MailMessage()
objEmail.To = "[email protected]"
objEmail.From = "[email protected]"
objEmail.Cc = "[email protected]"
objEmail.Subject = "Test Email"
objEmail.Body = x
SmtpMail.SmtpServer = "mail.domain.com"
Try
SmtpMail.Send(objEmail)
Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
End Try
When I get the email it comes with
http://www.domain.com/aaa/test/default2.aspx?date=1/13/2011
as a link
and the rest as text
11:39:09 AM&tfname=sadasd&tlname=asd&comp=GWI
Upvotes: 1
Views: 1446
Reputation: 4384
Whenever you put a parameter into a query string, you should encode it using System.Web.HttpUtility.UrlEncode to avoid invalid characters going into the URL:
x = "http://www.domain.com/aaa/test/default2.aspx?date=" & HttpUtility.UrlEncode(now.Text) &
"&tfname=" & HttpUtility.UrlEncode(p1fname.Text) &
"&tlname=" & HttpUtility.UrlEncode(p1lname.Text) &
"&comp=" & HttpUtility.UrlEncode(Request.QueryString("comp"))
Upvotes: 3
Reputation: 1497
You cannot have Spaces in the query string, if you need to put spaces, replace it with %20 before appending to the querystring. Although the ideal way to do this is to encrypt and decrpt the text in the querystring.
Upvotes: 2