Mail on Android - Attachment not ok

Hi,

with this sample of code, I can take a screenshot and add it as an attachment on iPad and iPhone. However with the same code on android,
the mail popup opens oke, but it failed to add the attachment.

local function sendEmailFromScreenShot()  
 local pictureDir = system.DocumentsDirectory   
 display.save(localGroup,"test.png",pictureDir)  
 native.showPopup("mail", {attachment = {baseDir=pictureDir,   
 filename="test.png" , type= "image"}})  
end  

Greetings,

Jürgen

ps: if you need more info, just let me now [import]uid: 19590 topic_id: 19798 reply_id: 319798[/import]

Jürgen,

I have confirmed that this is an issue. Only files from the resource directory can be successfully sent. It does not work from the Documents or Temporary directory (oops!). I am currently working on a solution. I expect to have a fix for this sometime this week. Thank you for reporting this issue. [import]uid: 32256 topic_id: 19798 reply_id: 77216[/import]

Joshua,

thank you for the quick feedback. It is a pleasure to use this framework and to be part of this community.

Big thx from Belgium,

Jürgen

ps: we’ll send you guys some business apps we’ve been working on the last couple of months because we know you guys are eager the get the business apps more in the spotlight. [import]uid: 19590 topic_id: 19798 reply_id: 77383[/import]

Jürgen,

This bug is now fixed. This fix will be made available in daily build #716. [import]uid: 32256 topic_id: 19798 reply_id: 77433[/import]

Joshua,

I’m gonna test this tonight in our business app on the samsung android, and i’ll provide some feedback.

regards,

Jürgen

[import]uid: 19590 topic_id: 19798 reply_id: 77513[/import]

The daily build containing this fix is now available. Sorry about the delay. We had some technical difficulties on our end. [import]uid: 32256 topic_id: 19798 reply_id: 78003[/import]

Joshua,

works perfectly now on the Samsung.
Thank you very much.
Jürgen [import]uid: 19590 topic_id: 19798 reply_id: 78470[/import]

Josh,

jpg attachment is not working on android. I have the same code above. jpg instead of png… [import]uid: 66859 topic_id: 19798 reply_id: 84253[/import]

MeApps,

Back in December, there was a bug on Android where it would fail to attach files from a directory other than the system.ResourceDirectory. That was fixed in the beginning of January. Please upgrade to the newest daily build and it should work. We’ve been able to send JPG files just fine on our side… along with PNGs and TXT files too. [import]uid: 32256 topic_id: 19798 reply_id: 84269[/import]

Hi Joshua,

Thanks for your respond. I figured what was wrong. See:

[lua]local options = {attachment = att}
native.showPopup(“mail”, options)
for w = 1, #att do
local path = system.pathForFile(att[w].filename, system.DocumentsDirectory )
if path ~= nil then
os.remove (path)
path = nil
end
end[/lua]

in iOS this works fine. I assume once native.showPopup is called with the attachment I can delete the files. However, on Android that do not work.

Can we have a listener for showPopup that let us know the user cancel or send the message that was popped up?

Thanks! [import]uid: 66859 topic_id: 19798 reply_id: 84819[/import]

MeApps,

Right, the native.showPopup() function is non-blocking on both iOS and Android. That means you were deleting your files before they were getting sent by the mail popup window. I think you’re just getting lucky on iOS and I’m surprised it worked at all considering that the IO calls such as io.remove() are blocking and would delete the files immediately. The file’s bits are still on storage, not zeroed out, so the popup may already have the stream at that point and you were getting really lucky, but it’s definitely not guaranteed.

Anyways, a Lua listener would be nice and I’ll write that up as a feature request. But what you can do “today” is delete your files when your app exits or suspends. We do this internally in Corona for other things we temporarily cache. [import]uid: 32256 topic_id: 19798 reply_id: 85015[/import]

Understood! I like your workaround however, that would be a problem if the user gets a phone call (suspends), true? Maybe I can put it in the temporary directory? Does that get cleared out by the OS, if so when?

Thanks!
[import]uid: 66859 topic_id: 19798 reply_id: 85019[/import]

Regarding the Lua listener, after thinking about it further, its not that simple. Just because the e-mail popup’s “Send” button was pressed does not mean the e-mail is sent immediately. It can take a long time to send due to a slow 3G or Edge connection… or it can be in the pending state because you do not have Internet access at all. Unfortunately, the mail client does not provide us events when the mail actually got sent (as far as I’ve seen). We only know when the mail popup is closed. So, this mean you need to hold on to the files and give the user the ability to manage the files themselves. For small temporary files, I suppose you just have to just hold on to them and re-use them the best you can.

Anyways, that’s my 2 cents. [import]uid: 32256 topic_id: 19798 reply_id: 85020[/import]

Got it. I think your workaround would be fine when the application exits.

While we are on the subject of e-mail attachments, are there any plans for compressing image files into zips and/or pdfs? Right now multiple files are attached separately. It would be nice to have the ability to compress the image files into zip or insert them into a single pdf.

Thanks! [import]uid: 66859 topic_id: 19798 reply_id: 85026[/import]

We currently do not support reading/writing to ZIP or PDF files. I agree that zip file support would be really nice and we’ve received many requests for that.

You might want to search the Internet for an open-source Lua library that supports zip files. It would have to be written in pure Lua to work (no binary dependencies), but if you can find something then that would solve this and not have to wait on us to implement it. [import]uid: 32256 topic_id: 19798 reply_id: 85034[/import]

Yes, so needed. Thats that thing, everything I have found for zips and pdfs has binary dependencies :frowning: [import]uid: 66859 topic_id: 19798 reply_id: 85036[/import]

Well, I’m sorry we’ve disappointed you here. We know this feature is important for business apps, which we want to focus more on this year. It sounds like you fall into this category, so hopefully what we release later down the road this year will interest you. [import]uid: 32256 topic_id: 19798 reply_id: 85039[/import]

Yes, our sports education apps are hybrid apps, a mixture of both. I am certain that you guys will to that. We are actually planning a trip to visit you guys and enlightened you guys about our apps and plans. We are steady in the top 50 in the app store in sports. So, these features and more are key to our success.

Thanks! [import]uid: 66859 topic_id: 19798 reply_id: 85042[/import]

Joshua,

neat that you guys are focussing on business apps this year, it is very welcome. We did already a few business proof of concepts for clients and I must say they were impressed with what they saw, but making the corona api more business minded, is always neat.

But if you think out of the box, a lot of things can be done with the current API, and as in every project the exotic features can be pulled down the product backlog.

I will email some of the business POC’s to ansca soon, when the POC are turned in to general ones.

Jürgen [import]uid: 19590 topic_id: 19798 reply_id: 85043[/import]

Joshua,

How can I get return a list of files from a directory?

Thanks! [import]uid: 66859 topic_id: 19798 reply_id: 89300[/import]