Last post Jun 10, 2010 12:42 AM by kdickie
Jun 09, 2010 06:31 PM|kdickie|LINK
I have a web page with an embedded gridview report. This page is passed three parameters in a query string, Begin Date, End Date and DivisionID. On this report page, I have a button (btnGenerateEmail) that when clicked opens an Outlook email editor and fills
in the cc, subject and a message in the body. My message in the body includes the url to the report web page.
My problem is that my url in the body of the email is returning a value like this which is missing the second and third parameter in the query string: http://localhost:3699/HRIC_EC/ECReport2.aspx?CIBD=4/1/2010
But it should be returning a value like this:
Here is my vb codebehind for my button:
Protected Sub btnGenerateEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerateEmail.Click
Dim strMessage As String = "Please click on this link and review the Employee Contracts: " & HttpContext.Current.Request.Url.AbsoluteUri
email = "mailto:?email@example.com&subject=Employee Contracts Request&body=" & strMessage
I believe that second and third ampersand & symbols in the entire url is the problem but I don’t know how to manipulate HttpContext.Current.Request.Url.AbsoluteUri so the correct url will appear in the body of the email.
Has anyone had a similar problem and if so how to you correct it?
Thanks in advance.
Jun 09, 2010 09:32 PM|Charith Gunasekara|LINK
Please use HttpContext.Current.Server.EncodeUrl("url");
Dim message As String = "Please click on this link and review the Employee Contracts: " + HttpContext.Current.Server.UrlEncode("http://localhost:3699/HRIC_EC/ECReport2.aspx?CIBD=4%2f1%2f2010&CIED=4%2f15%2f2010&DIV=8")
Dim email As String = "mailto:?firstname.lastname@example.org&subject=Employee Contracts Request&body=" & message
Jun 10, 2010 12:42 AM|kdickie|LINK
Thanks. That did it, it works great.