Page 1 of 1

Sending Mobile eMail with Attachment

Posted: Thu Nov 21, 2013 9:14 pm
by dcpbarrington
I'm using LiveCode V6.1.3 and trying to get my Android application to send a gmail message with an attachment.
I'm testing the application on Android V4.1.2.

I'm trying to send a log file along with a support e-mail message. Here is my code.

Code: Select all

function emailSupport
   put empty into tLogFileName
   
   -- Define the file name of the LOG FILE
   if the environment = "mobile" then
      set the defaultFolder to specialFolderPath( "documents" )
   else
      set the defaultFolder to specialFolderPath( "temporary" )
   end if
   put defaultFolder into tLogFileName
   put "/SaverHealth/STATlog.txt" after tLogFileName
   
   -- Define the Attachment Array with an attached file
   --put "text/plain" into tAttachment["type"]
   --put tLogFileName into tAttachment["file"]
   
   -- Test with basic data imput string
   put "This is a text data that is being attached to a support message" into tAttachment["Data"]
   put "text/plain" into tAttachment["type"]
   put "STATlog.txt" into tAttachment["name"]
   
   -- Define the eMail Details
   put "Support@SaverHealth.com" into toText
   put "Support" into subjectText
   put fld "message" into bodyText
   
   if environment() is "mobile" then
      mobileComposeMail subjectText, toText, , , bodyText, tAttachment
   end if
   
end emailSupport
The function works correctly and opens the Gmail application with the specified recipient, message and attachment file name.
HOWEVER when I send the message, I get an error Couldn't send attachment

I originally thought that it was because the attached file was a GZIP file, so I changed the file format to plain text file and that still failed.
SO I tried just sending a simple data string as shown above. It fails as well.

I'm sure there are others attaching data to an e-mail. What is going on???? This should send an attachment.

Thanks for the help.
dcpbarrington

Re: Sending Mobile eMail with Attachment

Posted: Fri Nov 22, 2013 5:03 am
by Simon
Hi dcpbarrington,
This has been noted as a bug
http://quality.runrev.com/show_bug.cgi?id=11069

I've been sitting here trying different methods but I can't get it to work either.
Go ahead and add your comments to the bug report.

Simon

Re: Sending Mobile eMail with Attachment

Posted: Fri Nov 22, 2013 5:16 pm
by dcpbarrington
Thanks Simon,

I will add my comments to the bug report.

Re: Sending Mobile eMail with Attachment

Posted: Sun Jan 19, 2014 2:00 am
by Mag
Hi all,

I'm trying to follow the suggested workaraound, unfortunately without luck.
The mobileComposeMail command is not able to read file data from within the application bundle (anything using specialFolderPath("engine")). You will need to either copy the file to a temporary location, i.e. specialFolderPath("temporary") or put the file data into the attachment["data"] key instead.
Maybe I'm doing something wrong in the code, or just the workaround don't work?

Code: Select all

   put specialFolderPath("temporary") into tFolder
   put tFolder&"/Photo.jpg" into myFilePath
   put the rect of image "myPhoto" into theRect
   export snapshot from rect theRect of this card to url ("binfile:"& myFilePath) as JPEG
   mergPopActivity emailBodyPhoto, myFilePath
The email arrives without attachment.

PS
mergPopActivity is a command of the mergAndroid External