Page 2 of 2

Re: send email with attachment

Posted: Sun Feb 17, 2019 3:16 pm
by simon.schvartzman
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

Re: send email with attachment

Posted: Mon Feb 18, 2019 6:04 pm
by jacque
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.

Re: send email with attachment

Posted: Tue Feb 19, 2019 1:33 am
by simon.schvartzman
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

Re: send email with attachment

Posted: Wed Feb 20, 2019 10:51 pm
by KimD
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

Re: send email with attachment

Posted: Tue Apr 23, 2019 8:31 pm
by simon.schvartzman
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

Re: send email with attachment

Posted: Mon May 13, 2019 6:49 am
by KimD
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.

Re: send email with attachment

Posted: Mon May 13, 2019 1:17 pm
by simon.schvartzman
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.

Re: send email with attachment

Posted: Mon May 13, 2019 10:41 pm
by KimD
Thanks Simon

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

Regards

Kim