The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) signs in the email body with blank space. It looks like it only happens with the +
sign. How can I remedy this? (I am working on a ASP.NET web page.)
https://mail.google.com/mail?view=cm&tf=0&[email protected]&su=some subject&body=Hi there+Hello there
(In the body email, "Hi there+Hello there" will show up as "Hi there Hello there")
URL encoding normally replaces a space with a plus (+) sign or with %20.
Generally speaking, the plus sign is used as shorthand for a space in query parameters, but while it can be used in such a way in URLs, it isn't a good idea. The plus sign is sometimes transformed into a space or to “%20” which can cause problems for the spiders crawling your site, hence causing issues with indexation.
Now, if you want a literal + to be present in the query string, you need to specify %2B instead. + sign in the query string is URL-decoded to a space. %2B in the query string is URL-decoded to a + sign.
URL encoding converts characters into a format that can be transmitted over the Internet. - w3Schools. So, "/" is actually a seperator, but "%2f" becomes an ordinary character that simply represents "/" character in element of your url. Follow this answer to receive notifications.
The +
character has a special meaning in a URL => it means whitespace -
. If you want to use the literal +
sign, you need to URL encode it to %2b
:
body=Hi+there%2bHello+there
Here's an example of how you could properly generate URLs in .NET:
var uriBuilder = new UriBuilder("https://mail.google.com/mail"); var values = HttpUtility.ParseQueryString(string.Empty); values["view"] = "cm"; values["tf"] = "0"; values["to"] = "[email protected]"; values["su"] = "some subject"; values["body"] = "Hi there+Hello there"; uriBuilder.Query = values.ToString(); Console.WriteLine(uriBuilder.ToString());
The result
https://mail.google.com:443/mail?view=cm&tf=0&to=someemail%40somedomain.com&su=some+subject&body=Hi+there%2bHello+there
If you want a plus +
symbol in the body you have to encode it as 2B
.
For example: Try this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With