I am sending emails from my iPhone app by calling a web service and in the email body I need to send a URL that contains an ampersand symbol (&). If I use the symbol in my URL the web service does not send the email, but if I remove that ampersand symbol everything works and the webservice sends the email just fine. So my question is, should I use the ASCII eqivalent of that symbol ? And if so, what is the ASCII eqivalent for '&'? Can any one help me?
This is my URL which has the ampersand symbol
http://xx.xxx.1.xx/xxx/aspxapprvcontrct.aspx?PartyEMail=xx#xxxx.com&devid= 1xx23
Thanks in advance.
You need to escape the whole string (email body) you are sending to your webservice. This question has been asked before on SO, see the link included below. I got it from the link #Caleb included, which in and of itself does not solve your particular problem. I would recommend looking at the second answer posted by #Michael Waterfall.
Objective C HTML escape/unescape
Related
I am having a wired issue in my AngularJs application. When user is trying to login to the app and if the password contains ampersand (&), then it couldn't able to validate the user.
I am using OWIN, oAuth2.0 JWT token to validate my Asp.Net Web APIs.
When i debug i found that if the password contains ampersand (&), then it is truncating all the characters from ampersand (&).
For example, if the password is 'x&x' the OAuthValidateClientAuthenticationContext context is getting only 'x' in password value.
I have attached a screen shot of the issue click to see the issue..
Any help on this issue, would be highly appreciated.
Am guessing the value is being interpreted as a query string separator.
Try using the javascript method
encodeURI()
Or
EncodeURIcomponent()
On your password value before posting to the server, so the ampersand becomes
&
The server will decode this for you.
You'll probably find that slashes and question marks will also not work in passwords if you dont
I had the same issue with an anguar project while entering special characters(ex: &, +) in password field. Encoding password with encodeURIComponent did the trick:
"&password=" + encodeURIComponent(password)
Hope it helps
I have a url in one of my emails for twitter share that looks like:
http://twitter.com/share?text=Praneeta%27s%20test&url=http%3A%2F%2Fwww.mydomain.com%3Fparam1%3D303%26param2%3Dtest&related=praneeta&via=Praneeta
However SendGrid converts only the part before the ' (encoded as %27)
So the url I have in the emails sent is broken and looks like
http://email.mydomain.com/wf/click?upn=<long_encoded_key>%27s%27s%20test&url=http%3A%2F%2Fwww.mydomain.com%3Fparam1%3D303%26param2%3Dtest&related=praneeta&via=Praneeta
Is there a work around for this?
note: If I copy the email html and send it to myself via putsmail, it works fine, it breaks only when it goes via Sendgrid.
I just sent the link you posted through my own SendGrid account and it looks like it was properly encoded. I wonder if this was a temporary issue? What happens if you try sending that link again?
Just a heads up on this issue incase if people stumble on this. The method should be escape for example:
CGI::escape('\'')
In my Windows 8 Store app, I have a Send Email button on a page and users are able to click it and send us an email for some general enquiries.
I need to pre-load some text in the email body but I can't seem to add line breaks to it. I tried Environment.NewLine and "\r\n". None of them works.
var mailto = new Uri("mailto:?to=james.jones#example.com&subject=Hello world&body=Hi," + Environment.NewLine + "Can you please ...");
await Windows.System.Launcher.LaunchUriAsync(mailto);
When I run it, I get "Hi,Can you please...". The line break is omitted.
Try using "%0d%0a" as your line break, as in
"Hi,%0d%0aCan you please..."
That's a URL-encoded ASCII CR/LF sequence. That works for me for the built-in Mail app but you don't have any particular guarantee that it would work for any arbitrary mail app that the user might install in the future.
The reason it doesn't work is because you're launching a Uri, Uris require that their contents be UrlEncoded / UrlEncodable. In the case of Environment.Newline etc you'd get an invalid Uri.
You can counter this by UrlEncoding the Environment Newline like this:
System.Net.WebUtility.UrlEncode(Environment.NewLine)
You maybe should consider using a Share Contract to share your content to your Mail App. Benefits: Users using your software can share it to other Apps, not only Email.
I'm trying to send information from obj-c to my php script, but as I've learned, I can't send text that has _'s in it. I'm using the $_GET[''] function in PHP and it won't accept when I send it spaces.
For example, when I send the data to the url in objective-c I get this:
http://test.com/test/test.php?url=http://test.com/test/images/2011-07-22/542.jpg&username=iMac&comment=test comment with space
Any recommendations?
Cheers,
Filip,
URL Encode it. That's what it's for.
is there anyway that I can use "mailto" with empty recipient? I only want to supply the subject and the message body and then the user can write the to addresses on mail. I tried writing only a space but it didn't work.
This should do, I tested it.
mailto:?subject=your%20subject&body=your%20body
And as HTML with correct escaping of the ampersand:
test
This should work..
test
I tried the accepted answer but it failed to launch an email when using Chrome. Using a %20 instead of a space worked though:
Send an Email