attaching a csv file to an email

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

attaching a csv file to an email

Post by newtronsols » Fri May 09, 2014 8:35 am

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Fri May 09, 2014 8:58 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: attaching a csv file to an email

Post by newtronsols » Fri May 09, 2014 2:13 pm

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?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Fri May 09, 2014 8:10 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: attaching a csv file to an email

Post by FourthWorld » Fri May 09, 2014 8:25 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Fri May 09, 2014 8:43 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: attaching a csv file to an email

Post by newtronsols » Fri May 09, 2014 10:56 pm

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Fri May 09, 2014 11:01 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: attaching a csv file to an email

Post by newtronsols » Fri May 09, 2014 11:18 pm

Thanks,

Just reading:

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

I will need to test these tomorrow.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Sat May 10, 2014 12:02 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: attaching a csv file to an email

Post by newtronsols » Sat May 10, 2014 4:51 pm

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Sat May 10, 2014 8:10 pm

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.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: attaching a csv file to an email

Post by newtronsols » Fri May 30, 2014 9:29 pm

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?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: attaching a csv file to an email

Post by jacque » Fri May 30, 2014 10:12 pm

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. ;)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: attaching a csv file to an email

Post by Simon » Fri May 30, 2014 11:51 pm

...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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “idea2app and Coding School”