709 - sending email

@Croisened

UPDATE:

I went to the Apple store and waited around for someone to emerge carrying a new ipad2 whereupon i leaped on them and hijacked the machine ran home and tested your code…It works perfectly…

CORONA GUYS/GALS (im pretty sure Peach isnt a guy!!)…email API does not appear work on an ipad1…build 715…IOS 5.0.1

p.s Im keeping the ipad2!! [import]uid: 85717 topic_id: 19297 reply_id: 76710[/import]

@sembleton

I have managed to get the email API to work on a iPad 1 build 715…IOS 5.0.1. No problems at all. I tested on my iPad using a Developer profile so not sure about a Ad Hoc profile (it should make no difference).

[lua]local mailOptions = {
to = {“blah@blahblah.com”},
subject=“Blah enquiry”,
body=“Dear Blah blah,”,
isBodyHtml = false
}
native.showPopup(“mail”, mailOptions)[/lua]

One little gotcha I can see with the below is dropping the {} round the to string.

Good to hear that it works on a iPad2 [import]uid: 22878 topic_id: 19297 reply_id: 76738[/import]

@zaphod8 (happy to see only one head!!)

i gotta wonder whats wrong with my ipad1 coz i cant get even the blank popup to work on it…your code above doesn’t do anything at all…and returns no errors…so im just scratchin my head…(in fact the client im doing this for only uses ipad2 so its almost a non issue :slight_smile: but i hate mysteries …and im as stubborn as they come when it comes to figuring out why code wont work…so…onward and downward :slight_smile: another day …another 25 cents…
thanks for the tip about the string i had missed that.
[import]uid: 85717 topic_id: 19297 reply_id: 76739[/import]

@sembleton
Hope you don’t mind me pushing on with trying to help resolve this mystery. I have created a main.lua with the full code of the email button. This has been tested on my iPad 1 with no problems.

Try this code out and see what happens.

[lua]local function emailBut(event)
if event.phase == “ended” then
local mailOptions = {
to = {“blah@blahblah.com”},
subject=“Blah enquiry”,
body=“Dear Blah blah,”,
isBodyHtml = false
}
native.showPopup(“mail”, mailOptions)
print(“touched the emailBut”)
end
end

local function main()
local myText = display.newRetinaText(“Email Button”, 500, 500, native.systemFont, 32)
myText:setTextColor(100, 255, 255)
myText:addEventListener( “touch”, emailBut)
end

main()[/lua]

When you click on the “myText” button in the simulator you should get a error in the terminal along with “touched the emailBut”:

ERROR: native.showPopup() does not support mail popups on this device. touched the emailBut

Hope the above helps. Let us know what was causing the problem. Most of the times I find its a missing character
[import]uid: 22878 topic_id: 19297 reply_id: 76744[/import]

copied and pasted into a new project…results:

ipad1…not working no popup …diddly squat.nada, nuffin, no reaction whatsoever
ipad2…works fine.
conclusion: shrugs shoulders and walks off to make tea

ill wipe the ipad1 later and then try again …maybe starting fresh will help…theres nothing of consequence on there it was just a test machine…Death to ipad1!! [import]uid: 85717 topic_id: 19297 reply_id: 76794[/import]

Everyone,

I’ve updated the API documentation and written up some example code to help clarify how to use the new mail/sms API. Particularly for multiple file attachments. Check it out via the link below…
http://developer.anscamobile.com/reference/index/nativeshowpopup

Regarding the iPad 1 e-mail issue, I’ll pass along this issue to our iOS developers. [import]uid: 32256 topic_id: 19297 reply_id: 77089[/import]

One for Ansca Staff…
Will it be possible in the near future to allow SMS popup with image attachments? MMS then i guess this would be
Thanks
[import]uid: 21298 topic_id: 19297 reply_id: 77119[/import]

I know MMS is possible on Android and I have already set up some of the code in anticipation of it. That said, it’s not going to happen on Android within the next month. We plan on adding the rest of the features promised in Carlos’ recent blog post (see link below) before creeping in any new features. Namely in-app purchase support.
http://blog.anscamobile.com/2011/12/state-of-the-corona-address/
[import]uid: 32256 topic_id: 19297 reply_id: 77124[/import]

Hi Joshua
Is it possible to send emails without the need for the popup…fill in a data structure and just send it?? [import]uid: 85717 topic_id: 19297 reply_id: 77200[/import]

sembleton,

I believe you can already do this via Lua “sockets.smtp”. The downside being is that you do not have access to the device’s default mail client settings such as STMP server, port number, etc. In fact, I don’t think we even have access to those settings on iOS or Android which is why it is done via built-in popup windows.

Here is a link to a forum post where someone claims to have gotten an STMP client working in Corona…
http://developer.anscamobile.com/forum/2011/12/28/smtp-send-email-attachment-using-luasocket
[import]uid: 32256 topic_id: 19297 reply_id: 77212[/import]

@sembleton, we can’t reproduce this. Just tried it running on iPad 1 with iOS 5.0 (9A334) and it works. This is the code we used (modified version of the HelloWorld sample):

[lua]local background = display.newImage( “world.jpg” )

local myText = display.newText( “Hello, World!”, 0, 0, native.systemFont, 40 )
myText.x = display.contentWidth / 2
myText.y = display.contentWidth / 4
myText:setTextColor( 255,110,110 )
native.showPopup( “mail”, {
attachment={baseDir=system.ResourceDirectory, filename=“world.jpg”, type=“image”}
} )[/lua] [import]uid: 26 topic_id: 19297 reply_id: 77423[/import]

Everyone,

There was a bug on Android where file attachments from a directory other than the ResourceDirectory would fail to be sent with the e-mail. This will be fixed in daily build #716. [import]uid: 32256 topic_id: 19297 reply_id: 77434[/import]

UPDATE…

My ipad 1 in now officially no more…i killed it off and rebirthed it as a new ipad and low and behold the email stuff all works now…praise de lard!!

I have no idea what screwed it up … [import]uid: 85717 topic_id: 19297 reply_id: 77833[/import]

guruk,

The file attachment problem on Android was fixed since build #716. Since then, we’ve received no reported bugs related to e-mail on Android. Please use the newest daily build and let us know if it worked for you. Thanks! [import]uid: 32256 topic_id: 19297 reply_id: 81373[/import]

have EXACTLY the same problem…
did you solved it?

iOS fine…
Android … Attachment Failed
---- UPDATE

with latest Night Build it worked :slight_smile:
was still on 715

[import]uid: 4795 topic_id: 19297 reply_id: 81371[/import]

For people who have had problems getting email to work (as we did), make sure you have an email account configured.

I have no idea why Corona has an issue if you don’t have any email configured, but basically it just fails silently. Other (non-Corona) apps have no problem showing a option to the user to setup or configure their mail; something that looks like it is an Apple interface.

So, my wish list item for email/sms support is PLEASE test it on a device that does not have email configured. Then make it work like other apps.

Thanks! [import]uid: 16734 topic_id: 19297 reply_id: 89661[/import]

Ken,

We’re already aware of this issue and we have tested for it… which is why it doesn’t crash. What we “need” to do next is provide an API that detects if the device is capable of sending mail or SMS. We plan on providing the following API in the near future to do exactly this…

[lua]native.canShowPopup(“mail”)[/lua]

All in due time. Our new mail/SMS API is not part of the release build yet and our daily builds are pre-alpha/beta versions for our community to evaluate our newest features/enhancements to provide us feedback. Use them at your own risk. But that said, we very much appreciate the community’s feedback on things such as this, because it allows us to make a better product in the end for everyone. Just me 2 cents. [import]uid: 32256 topic_id: 19297 reply_id: 89677[/import]

@Joshua,

Thank you for the update. It’s good to know this is on your radar. I totally understand that these daily builds are “use at your own risk”.

I was just trying to save other people some time in case they were having the same issue.

Ken [import]uid: 16734 topic_id: 19297 reply_id: 89687[/import]

@Joshua it is great that you guys pushed it out, I’m happy to find as many bugs as I can, and I got it to work well…

An api for SMS would be great too. Maybe something like this:

native.showPopup("sms", {to={"4153333333"}, body="I scored 2054 in this game, can you beat me?", attachement={}, listener=null})  

[import]uid: 22829 topic_id: 19297 reply_id: 74475[/import]

@Joshua thanks so much! Please take a well deserved break!

Thanks
Hoan
[import]uid: 22829 topic_id: 19297 reply_id: 75240[/import]