Page 1 of 1

attaching a csv file to an email

Posted: Fri May 09, 2014 8:35 am
by newtronsols
I am using 6.6.1 - trying to send a csv file as an email attachment from Android but without success

using:
put specialFolderPath("documents") into tFilePath
put tFilepath into tAttachment["file]"
put "test.csv" into tAttachments["name"]
put "text/plain[or csv]" into tAttachments["type"]
mobileCompose[or Unicode]Mail "subject..", tAddress,,,tBody, tAttachment


Any suggestions.

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 8:58 am
by Simon
Hi newtronsols,
You are putting a path to the file in not the file:

Code: Select all

  put url("file:" &specialFolderPath("documents") & "/test.csv") into tFile
   put  tFile into tAttachment["data"]
   put "text/csv" into tAttachment["type"]
   put "test.csv" into tAttachment["name"]
   mobileComposeMail "File Example", "you@youMailHost.com",,,, tAttachment
And Android attachments currently only work with gMail.

Simon

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 2:13 pm
by newtronsols
Thanks I'll give that a try. Is there a way to make Livecode use Gmail - or does it need to be set as the default email account?

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 8:10 pm
by Simon
Hi newtronsols,
Apparently I'm mistaken;
put specialFolderPath("documents") into tFilePath
put tFilepath into tAttachment["file]"
should work, it is reported as a bug at the moment.

I think the default email client has to be set in the device by the user not via liveCode.

Simon

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 8:25 pm
by FourthWorld
Is the goal to allow the user to send an email with this data to anyone they want, or to get that data to a specific recipient?

And must the data be specifically CSV?

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 8:43 pm
by Simon
Rats didn't read what I was posting.
This is what should work but is broken
put specialFolderPath("documents") & "/test.csv" into tFilePath
put tFilePath into tAttachment["file"]
So file path is [file]
the actual file is [data]

Simon

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 10:56 pm
by newtronsols
FourthWorld wrote:Is the goal to allow the user to send an email with this data to anyone they want, or to get that data to a specific recipient?

And must the data be specifically CSV?
Yes the idea is they can send it to anyone or themselves. I was hoping to be able to use any email system - I'm not sure what percentage of Android users use Gmail.

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 11:01 pm
by Simon
Hi newtronsols,
Could you post your device information here
http://quality.runrev.com/show_bug.cgi?id=11895
This is very hot now, it's currently right in front of them.

Simon

Re: attaching a csv file to an email

Posted: Fri May 09, 2014 11:18 pm
by newtronsols
Thanks,

Just reading:

put tFilename into tAttachment["file"]
or
put url("binfile:" & tFilename) into tAttachment["data"]

I will need to test these tomorrow.

Re: attaching a csv file to an email

Posted: Sat May 10, 2014 12:02 am
by Simon
Hi newtronsols,
I've never actually tested
put url("binfile:" & tFilename) into tAttachment["data"]
It does read correctly but this is the way I currently doing it
put url("file:" &specialFolderPath("documents") & "/test.csv") into tFile
put tFile into tAttachment["data"]

Simon

Re: attaching a csv file to an email

Posted: Sat May 10, 2014 4:51 pm
by newtronsols
I have tested :

put "email body text" into tBody
put "text/csv" into tAttachment["type"]
put "test.csv" into tAttachment["name"]
put url(specialFolderPath("documents") & "/test.csv") into tFile
#then either put tFile into tAttachment["data"] or
put url("file:" & tFile) into tAttachment["data"]
mobileComposeMail "Subject", tAddress,,,tBody, tAttachment

But still no attachment. Note not testing with gmail. I also tested using 'binfile' - just in case.

Re: attaching a csv file to an email

Posted: Sat May 10, 2014 8:10 pm
by Simon
Hi newtronsols,
I've only heard of one person getting attachments to work on Android without using gMail and he's at RunRev. No one else has reported it working, it is still an open bug.
Android gMail - works
Android Email - doesn't work (for me and a few others).

Simon
Edit: Please add your information to the bug report found at the link above.

Re: attaching a csv file to an email

Posted: Fri May 30, 2014 9:29 pm
by newtronsols
This now works in 6.6.2 rc4 or 5.
see http://quality.runrev.com/show_bug.cgi?id=11895#c32

My other questions:
...the attachment shows an android robot icon next to the test.csv attachment file name - can we personalise this attachment icon?

Also I have noticed if I build a different version of the same app (simply changing the label & identifier) - data previously saved in the 'documents' folder is not retrieved. I haven't tested updating an app in Google Play - to see if it retrieves previously stored phone data in the app's documents folder.

So are these document specialfolderpaths 'relative' to the built version (label) of the app - and not absolute document folder locations shared by all apps?

I was thinking if I had a paid version and a free version of an app I would want to be able to re-use the data stored from the free version in the paid version which would have its own label/identifier.

Is it possible to specify a specialfolderpath that allows data to be accessible by any app?

Re: attaching a csv file to an email

Posted: Fri May 30, 2014 10:12 pm
by jacque
The documents folder is a virtualized folder available only to your app. This is true of most (or all?) Android apps, due to sandboxing. Malware would love to have access to every document on your device. ;)

Re: attaching a csv file to an email

Posted: Fri May 30, 2014 11:51 pm
by Simon
...the attachment shows an android robot icon next to the test.csv attachment file name
My guess is that is the default because the device has not file type association. Bet if you changed the extension to .xls an Excel icon would be there. Actually in your case probably not because Excel would pick up the csv.
can we personalise this attachment icon?
Not that I know of, except to build another app that associates csv with itself.

Simon