- Home /
Unity "Application.OpenURL" Doesnt work.
Hi,
I'm trying to use this code to open up email composer:
Application.OpenURL("mailto:email@hotmail.com?subject=Email&body=Unity");
but the problem is it doesn't work. I replaced the url with "www.google.com" and it works fine but as soon as I replace it with mailto, doesnt work.
I even used "mailto:email@hotmail.com?subject=Email&body=Unity" on my browser and it works.
Can someone please help me with this. Is there anything I should do in Unity before using "mailto"?
Thanks.
On the editor it doesnt do anything and on Android it crashes. but OpenURL for websites works fine on both.
Answer by CapeGuyBen · May 19, 2015 at 10:11 AM
I was also having difficulties with this which turned out to be a need to escape some characters (like spaces etc.) in the mail subject. This can be done using System.Uri.EscapeDataString.
string mailSubject = System.Uri.EscapeDataString ("Email from my Unity app");
string mailRecipient = "not_real@umail.com";
string mailURL = "mailto:" + mailRecipient + "?subject=" + mailSubject;
Application.OpenURL(mailURL);
Answer by shinriyo_twitter · Jun 15, 2012 at 12:10 PM
i did Unity editor and iPhone.
Application.OpenURL("mailto:email@hotmail.com?subject=Email&body=Unity");
I guess Android is only Pro.
But $$anonymous$$e doesnt even do anything in the editor. that's the problem. opening an URL is fine but not mailto... is there something wrong with my unity software? I just upgraded to the latest one a few days ago.
Answer by ramkumarm · May 28, 2014 at 09:04 AM
Hi I tried with unity 4.2 pro , andorid working fine , Thank you
Your answer
