Sending Mobile eMail with Attachment

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Sending Mobile eMail with Attachment

Post by dcpbarrington » Thu Nov 21, 2013 9:14 pm

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

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

Re: Sending Mobile eMail with Attachment

Post by Simon » Fri Nov 22, 2013 5:03 am

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

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Sending Mobile eMail with Attachment

Post by dcpbarrington » Fri Nov 22, 2013 5:16 pm

Thanks Simon,

I will add my comments to the bug report.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Sending Mobile eMail with Attachment

Post by Mag » Sun Jan 19, 2014 2:00 am

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

Post Reply