Skip to content

Instantly share code, notes, and snippets.

@kankikuchi
Last active November 6, 2024 12:37
Show Gist options
  • Save kankikuchi/3022c9930cf2ddc19167 to your computer and use it in GitHub Desktop.
Save kankikuchi/3022c9930cf2ddc19167 to your computer and use it in GitHub Desktop.
端末情報を付けたメール機能【Unity】
/*ブログ説明用
PlayerSettingsValue.PRODUCT_NAME = アプリ名
*/
//メール
private const string MAIL_ADRESS = "送信先のメールアドレス";
private const string NEW_LINE_STRING = "\n";
private const string CAUTION_STATEMENT = "---------以下の内容はそのままで---------" + NEW_LINE_STRING;
/// <summary>
/// メーラーを起動する
/// </summary>
public void OpenMailer(){
//タイトルはアプリ名
string subject = PlayerSettingsValue.PRODUCT_NAME;
//本文は端末名、OS、アプリバージョン、言語
string deviceName = SystemInfo.deviceModel;
#if UNITY_IOS && !UNITY_EDITOR
deviceName = iPhone.generation.ToString();
#endif
string body = NEW_LINE_STRING + NEW_LINE_STRING + CAUTION_STATEMENT + NEW_LINE_STRING;
body += "Device : " + deviceName + NEW_LINE_STRING;
body += "OS : " + SystemInfo.operatingSystem + NEW_LINE_STRING;
body += "Ver : " + PlayerSettingsValue.BUNDLE_VERSION + NEW_LINE_STRING;
body += "Language : " + Application.systemLanguage.ToString () + NEW_LINE_STRING;
//エスケープ処理
body = System.Uri.EscapeDataString(body);
subject = System.Uri.EscapeDataString(subject);
Application.OpenURL("mailto:" + MAIL_ADRESS + "?subject=" + subject + "&body=" + body);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment