send email with attachment

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: send email with attachment

Post by simon.schvartzman » Sun Feb 17, 2019 3:16 pm

Hi guys, I'm trying to use the hints given in this thread but failing miserably

This is my code:

Code: Select all

	set the umask to 002
         put ("auxfile.jpg") into tFileName
         put specialFolderPath("documents") & "/" & tFileName into pFilePath -->  --> EXTERNAL STORAGE!
         export snapshot from group "Group 1" of card "Capture" to temp as JPEG
         put temp into URL ("file:&pFilePath")
         answer "Sending the file…" & cr & pFilePath & cr & (there is a file pFilePath) -->"TRUE
         put pFilePath into tAttachment["file"]
         put "image/jpg" into tAttachment["type"]
         put tFileName into tAttachment["name"]
         put "Here's the file!" into tBody
         put "Sending a file" into tSubject
         mobileComposeMail tSubject, , , , tBody, tAttachment  --> SUCCESS!!!
If I use:
put specialFolderPath("documents")...
the attachment is shown in the email composer but is not delivered (as expected according to this thread).

When I use:
put specialFolderPath("external documents")...
The file can't be found on the "external documents" and of course is neither shown nor delivered...

Note 1: Write External Storage is set on the standalone settings.

Note 2: I'm using LC 8.1.10 (because 9.02 gives me a black screen on my device) an Android 5.1

Note 3: I've tried "Prefer External Storage" in the Install Location settings as suggested by Jacque in another thread but made no difference

What am I doing wrong? Thanks
Simon
________________________________________
To ";" or not to ";" that is the question

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

Re: send email with attachment

Post by jacque » Mon Feb 18, 2019 6:04 pm

I haven't ever needed to do this but I think my next step would be to skip the file entirely and just use mobileComposeMail's data option. You've already got the binary data in the temp variable so try just sending that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: send email with attachment

Post by simon.schvartzman » Tue Feb 19, 2019 1:33 am

Thanks for your suggestion Jacque. As a matter of fact I landed in this post because my first attempt with a "clean" version didn't work (meaning the picture was not included in the email as an attachment)

This is my original code:

Code: Select all

 
 	 export snapshot from group "Group 1" of card "Capture" to image "AuxImg" as JPEG
         put  image "AuxImg" into tAttachment["data"]
         put "image/jpg" into tAttachment["type"]
         put "my picture" into tAttachment["name"]
         mobileComposeMail "Imagem Capturada", ,,,, tAttachment
it works on Android 5.1.1 but doesn't on Android 5.1.

I ended up filing a bug report https://quality.livecode.com/show_bug.cgi?id=21843

p.s.: between you and me (and everybody else that reads this post) I'm feeling uncomfortable to release an App on Android due to the problems (3 so far) I'm encountering when testing on 5.1
Simon
________________________________________
To ";" or not to ";" that is the question

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: send email with attachment

Post by KimD » Wed Feb 20, 2019 10:51 pm

On Android 5.0.1, using "mobileComposeMail tSubject,,,,tEmailBody, tAttachment":

- did NOT work if tAttachment was located in specialFolderPath("documents"). The email, with attachment, was composed. Gmail could clearly "see" the attachment, because it correctly told me what size the attachment was. The email was sent, but when it arrived the attachment was missing.

- DID work if tAttachment was located in specialFolderPath("external documents"). The email was sent and when it arrived the attachment was present.

Thanks for the "external documents" tip!

Kim

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: send email with attachment

Post by simon.schvartzman » Tue Apr 23, 2019 8:31 pm

Hi all, having problems (again) with mobileComposeMail and Android 9.0

The same App (built with LC 9.3) that works fine on devices with Android 6.0 and up fails on a Huawei P10 mate Pro running Android 9.0.

The picture file doesn't attach to Gmail ("unable to attach file" is shown in the screen) nor is it added to the WhatsApp dialog.

Anyone has seen the same behaviour? Just asking before filing a bug report.

Thanks
Simon
________________________________________
To ";" or not to ";" that is the question

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: send email with attachment

Post by KimD » Mon May 13, 2019 6:49 am

The below works on Android 5.0.1 but not on Android 8.1.0

local tSubject, tEmailBody, tAttachment
put "You must read this" into tSubject
put "Dear Colleague. Blah Blah Blah" into tEmailBody
Put URL("file:" & ggDocumentsFolder & slash & myFilename ) into url("file:" & specialfolderpath("external documents") & slash & myFilename)
put specialfolderpath("external documents") & slash & myFilename into tAttachment["file"]
put myFilename into tAttachment["name"]
put "text/plain" into tAttachment["type"]
mobileComposeMail tSubject,,,,tEmailBody, tAttachment

1) On Android 8.1.0 the Gmail app displays an error message "Unable to attach file."

2) ANSWER there is a file (specialfolderpath("external documents") & slash & myFilename) reports TRUE on both devices

3) I tried removing the tAttachment["name"] and tAttachment["type"] statements. This did not alter the result. The code still worked on Android 5.0.1 but not on Android 8.1.0.

4) I tried writing the file into the devices Downloads directory (instead of External Documents). This still didn't work on Android 8.1.0; but if I started the Gmail app "manually" and manually attached the file then it worked fine.

Tomorrow will try the tAttachment["data"] alternative.

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: send email with attachment

Post by simon.schvartzman » Mon May 13, 2019 1:17 pm

What version of LC are you using? LC 9.0.4 rc 2 is supposed to fix this issue. It did for me...

Hope it helps.
Simon
________________________________________
To ";" or not to ";" that is the question

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: send email with attachment

Post by KimD » Mon May 13, 2019 10:41 pm

Thanks Simon

Going from LC 9.00 to LC 9.04 seems to have fixed this for me also.

Regards

Kim

Post Reply

Return to “Android Deployment”