playMaker

Author Topic: Application Open Url Mailto  (Read 4295 times)

klvo

  • Playmaker Newbie
  • *
  • Posts: 13
Application Open Url Mailto
« on: June 17, 2014, 05:13:39 AM »
Hi,

This is a modified version of Application Open Url, so that it will only generate a mailto link, with the option to add a Subject and Body text.
It will get rid of the formatting problems that sometimes happen when adding text to fields in Application.OpenURL

I tested only on iOS and the editor, but it should work in any platform where Application.OpenURL is supported.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Application)]
[Tooltip("Open a Mailto Url link in the browser or email client")]
public class ApplicationOpenUrlMailto : FsmStateAction
{

[Tooltip("Email Address")]
public FsmString inputEmail;

[Tooltip("Subject")]
public FsmString inputSubject;

[Tooltip("Body")]
public FsmString inputBody;



public override void OnEnter()
{

string email = inputEmail.Value;
string theSubject = inputSubject.Value;
string theBody = inputBody.Value;

string subject = MyEscapeURL(theSubject);
string body = MyEscapeURL(theBody);

Application.OpenURL("mailto:" + email + "?subject=" + subject + "&body=" + body);

Finish();
}

string MyEscapeURL (string url)
{
return WWW.EscapeURL(url).Replace("+","%20");
}
}
}

I hope someone else finds it useful.
Cheers

Dakk

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 21
Re: Application Open Url Mailto
« Reply #1 on: May 06, 2020, 11:02:01 PM »
Jean,
This is really old, but should be added to the EcoSystem- with the small update to UnityWebRequest instead of WWW.  Very nice and saved me issues with formatting for mobile.
Thanks,
Dakk

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Application Open Url Mailto
« Reply #2 on: May 26, 2020, 02:42:20 AM »
Hi,

WWW usage here would still be valid right? it's only to escape chars. or do you hit problem with that?

Bye,

 Jean