Send email from within app using phone's default mail account

Hi there,

I think a useful function for Corona would be to have the ability to send an email using your phone’s default mail account and attach items from within your app such as from a text field or a picture. Using a very simple example, lets say you have a note taking app where you can type in a text field. You would be able to have an email button that would create an email with these notes in the body. [import]uid: 31262 topic_id: 6613 reply_id: 306613[/import]

+1 [import]uid: 10968 topic_id: 6613 reply_id: 33203[/import]

+2 [import]uid: 13859 topic_id: 6613 reply_id: 42237[/import]

+1

Can Carona add an email function that would perform like the “Tell a Friend” feature in the app store (in each app below the ratings label)? [import]uid: 40033 topic_id: 6613 reply_id: 42252[/import]

Theres a way you can “send email” through your application. Its kind of a hack but it works. You won’t be able to attach any images or files but you can prewrite text.

What you need to do is to send a url request to the device and ask it to launch email.

Here’s an example,

system.openURL( "mailto:?subject=Cool%20Subject&body=Thisisthebody")

Source for more parameters:
http://email.about.com/od/mailtoemaillinks/a/mailto_elements.htm [import]uid: 11917 topic_id: 6613 reply_id: 42343[/import]

+1
This is so needed by our published app right now!! Woke up to 8 users wanting this…

Willy J.
[import]uid: 66859 topic_id: 6613 reply_id: 52916[/import]

+1 [import]uid: 84627 topic_id: 6613 reply_id: 53626[/import]

+1 [import]uid: 13553 topic_id: 6613 reply_id: 53649[/import]

+1 [import]uid: 53732 topic_id: 6613 reply_id: 55094[/import]

  • 1 [import]uid: 87837 topic_id: 6613 reply_id: 55151[/import]

+1 [import]uid: 50842 topic_id: 6613 reply_id: 55152[/import]

The method posted by Clement is what I use in my apps. Works swimmingly. [import]uid: 5317 topic_id: 6613 reply_id: 55162[/import]

…but unfortunately without file attachment. [import]uid: 53732 topic_id: 6613 reply_id: 55164[/import]

But can you use Clements method to somehow send dynamic text? Like grab text from a text field or a variable? [import]uid: 31262 topic_id: 6613 reply_id: 55191[/import]

The method Clement suggested works flawlessly. Albeit without attachments [import]uid: 84637 topic_id: 6613 reply_id: 55210[/import]

Clement’s way is great.

aaaron: I concatenated variables into it… ie:

system.openURL( “mailto:?subject=Cool%20Subject&body=Thisisthebody and”…player1…“is the winner today”)

seemed to work; hope it helps

Anyone: In the simulator I can just send the email and it goes and all is well…however I’m having a problem when I build for device (ios)
It works great when I click on the email button in my program and I can send the message, but I then become stuck in the email program and can’t return without restarting my app. Does anyone who’s made this work know if there is some kind of onComplete listener or something that I should be using? [import]uid: 57883 topic_id: 6613 reply_id: 55250[/import]

Clements method works but on iOS it exists the application after the email is sent.

It would be great to be able to send an email within the app and attachments will be wonderful.

Shahar [import]uid: 13553 topic_id: 6613 reply_id: 55274[/import]