- Home /
get information from external application
Hi, I opened my default mail client from my system using, using UnityEngine; using System.Collections;
public class sendMail : MonoBehaviour
{
void OnGUI ()
{
if(GUI.Button(new Rect(100, 100, 80, 40), "send mail"))
Application.OpenURL("mailto:xx@yy.com?subject=hi&body=test");
}
}
its working fine, i like to get a message from that application (eg. outlook) to unity when user selects send button. Please send me solution.
Regards, Ben
Answer by shaderop · Oct 08, 2012 at 10:12 AM
This is going to be difficult to do and will depend on the email client and the operating system in question. On Windows you could to it by listening to the Win32 messages raised by the email client, but you have to know or somehow detect the HWND of the "send" button or its equivalent in your email application.
It would be much easier if you set your Unity application to _not_ run in the background, and then listen to the OnApplicationFocus event. And when your application regains focus after the user presses the send mail from inside your application, either ask the user if they have sent the email or simply assume that they did.
EDIT
Or, if you're sure that Outlook is going to be the default email client, you can use COM and C# to send a message through Outlook.
Thanks shaderop. Iam using windows system and outlook as my default mail client setup.
Regards, Ben
Your answer
Follow this Question
Related Questions
Send HTML email from iOS app 1 Answer
How to send an Email with the details entered in a json file? 0 Answers
how to make a built game interface- navigation into a link available online 0 Answers
Quit or close unity on button click and send user to Android native app 0 Answers
My app freezes on specific y coordinates 0 Answers