This is code that makes it possible to send an email on windows phone 8 from lua:
Add to the top of MainPage.cs:
using CoronaLabs.Corona.WinRT; using Microsoft.Phone.Tasks;
Add the following to your OnCoronaRuntimeLoaded function in MainPage.cs:
e.CoronaRuntimeEnvironment.AddEventListener("SendMail", SendMail\_Listener);
Add the listener function at the bottom of MainPage.cs:
public ICoronaBoxedData SendMail\_Listener(CoronaRuntimeEnvironment sender, CoronaLuaEventArgs e) { string to = (e.Properties.Get("to") as CoronaBoxedString).ToString(); string subject = (e.Properties.Get("subject") as CoronaBoxedString).ToString(); string body = (e.Properties.Get("body") as CoronaBoxedString).ToString(); EmailComposeTask emailComposeTask = new EmailComposeTask(); emailComposeTask.To = to; emailComposeTask.Subject = subject; emailComposeTask.Body = body; emailComposeTask.Show(); return CoronaBoxedBoolean.True; }
Lua Code to send mail:
local result = Runtime:dispatchEvent({ name = "SendMail", to = "example@foo.bar", subject = "Subject Line", body = "Body text here" });