Does Application.OpenURL("mailto:address@domain.com") work for popping up a native email prompt on mobile? doco
–
It’s well worth noting that if you just want to send a very simple one with NO dynamic text, no body, no unusual characters, just replace the spaces with %20 manually like so:
public void LinkHelpEMAIL()
{
string t =
"mailto:blah@blah.com?subject=Question%20on%20Awesome%20Game";
Application.OpenURL(t);
}
exactly like that (do not escape the at symbol). saves typing, tested on both.
Note, this explanatory example code, does not literally work, as you must escape certain strings. Teaching code only.
Yes. Using Application.OpenURL() you could open safari, maps, phone, sms, mail, youtube, itunes, app store and books store. You could find all the url schemes you could need here These are for Objective-C but if you get the idea of the url scheme it would be really easy to do it on Unity. Here you have an example of a simple script to send a mail with address, subject and body.
C# mail example:
public string email;
public string subject;
public string body;
// Use this for initialisation .. EXAMPLE ONLY, DOES NOT WORK
void Start () {
Application.OpenURL("mailto:" + email + "?subject:" + subject + "&body:" + body);
}
Please note that there is no reliable way to add any attachments with mailto, you’ll have to use underlying platforms email API with native plugins to achieve that.
We’ve recently published a new asset UTMail - Email Composition and Sending Plugin, which supports composing emails with attachments and also sending them directly with SMTP. It works on multiple platforms and provides a convenient API.