Emailing an attachment

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Emailing an attachment

Post by tyarmsteadBUSuSfT » Sat Feb 22, 2014 2:23 pm

Hello,
I noticed the the latest release indicated that the bug had been fixed for the email attachment error. I tried this code and while I can see the attachment prior to sending it does not send the attachment.
on mouseup
mobileSetKeyboardType "email"
   Ask "Send to what email address?"
   put it into tAddress
   set the itemdel to tab
if it = empty then
         exit to top
end if
put specialFolderPath("engine") & "/Compost.pdf" into tFilePath
answer tFilePath
put tFilePath into tAttachment["file"]
put tURL & ".pdf" into tAttachment["name"]
put "application/pdf" into tAttachment["type"]

put "Hello, Here's an attachment about Compost:" after tText
            set itemdel to tab
            if the environment is "mobile" then
               mobileComposeMail "Compost" & tURL, tAddress,,, tText, tAttachment 
               else
            Revmail tAddress, , "Get WSU Master Gardener Fact Sheets at:", tText
            end if
end mouseup

Thank you
Ty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Sat Feb 22, 2014 2:34 pm

Hi Ty,

quick shot:
...
put tURL & ".pdf" into tAttachment["name"]
...
tURL has not been filled with content so far!


Best

Klaus

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Sat Feb 22, 2014 3:22 pm

Thank you Klaus, but I've got to ask again, because I'm just not getting it.
I want to export and email a screen shot.

mobileSetKeyboardType "email"
set the defaultFolder to specialFolderPath("documents")
export snapshot from this card to URL ("file:" & specialFolderPath("documents") & "/Color.jpg") as JPEG
 local tSubject, tTo, tCCs, tBCCs, tBody, tAttachment
put empty into lvLaunchString     
put specialFolderPath("documents") & "/Color.jpg" into tFilePath
put tFilePath into tAttachment["path"]
put "color.jpg" into tAttachment["file"]
put "MyColor.jpg" into tAttachment["name"]
put "image/jpg" into tAttachment["type"]
mobileComposeMail tSubject, tTo, tCCs, tBCCs, tBody, tAttachment

I've tried putting tFilePath into the tAttachment["file"]
I know it is simple, but I can't see it.
Thank you for your help
Ty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Sat Feb 22, 2014 3:28 pm

HI Ty,

hmmm, looks definitivel correct! Is this with LC 6.6 DP1?

You could "answer the result" after the composemail command,
but that will only return "unknown" on error on Android.


Best

Klaus

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Sat Feb 22, 2014 3:38 pm

It is with 6.6.0-dp|build
Should I file a bug report?

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Sat Feb 22, 2014 3:57 pm

Hi Ty,

no wait, I think I got it :D

..
put specialFolderPath("documents") & "/Color.jpg" into tFilePath

## Invalid key for attachment -> path!
## put tFilePath into tAttachment["path"]

## Need an absolute pathname here:
## put "color.jpg" into tAttachment["file"]

## This should do the trick:
put tFilePath into tAttachment["file"]

put "MyColor.jpg" into tAttachment["name"]
put "image/jpg" into tAttachment["type"]
mobileComposeMail tSubject, tTo, tCCs, tBCCs, tBody, tAttachment
...

Best

Klaus

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Sat Feb 22, 2014 7:31 pm

Still didn't work:

mobileSetKeyboardType "email"
local tSubject, tTo, tCCs, tBCCs, tBody, tAttachment
put empty into lvLaunchString  
set the defaultFolder to specialFolderPath("documents")
export snapshot from this card to URL ("file:" & specialFolderPath("documents") & "/Color.jpg") as JPEG
put specialFolderPath("documents") & "/Color.jpg" into tFilePath
put tFilePath into tAttachment["file"]
put "MyColor.jpg" into tAttachment["name"]
put "image/jpg" into tAttachment["type"]
mobileComposeMail tSubject, tTo, tCCs, tBCCs, tBody, tAttachment

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Sat Feb 22, 2014 7:39 pm

Hi Ty,

aha! :D

Try this:

Code: Select all

...
put the windowID of this stack into tWinID
export snapshot from rect (the rect of this card) of window tWinID to FILE (specialFolderPath("documents") & "/Color.jpg") as JPEG 

## Alway good to check THE RESULT after these kind of operations!
if the result <> empty then 
    answer "ERROR:" && the result
    exit to top
end if
...
Best

Klaus

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Sat Feb 22, 2014 9:04 pm

Thanks Klaus,
But it is stopping at the export snapshot line.
Ty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Sun Feb 23, 2014 12:19 am

Hi Ty,

oh, sorry, old desktop habits, "windowID" is not supported on mobile! 8)

This should do the trick:
...
## put the windowID of this stack into tWinID
export snapshot from rect (the rect of this card) to FILE (specialFolderPath("documents") & "/Color.jpg") as JPEG
...


Best

Klaus

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

Re: Emailing an attachment

Post by Simon » Sun Feb 23, 2014 5:48 am

I finally got around to testing this.
Big trick; Disconnect your phone from the computer. Seems the sd card is used during this process and cannot be accessed while connected.
Worked with gMail.

You can skip the rest:

Code: Select all

on mouseUp
   put image 1 into tAttachment["data"]
   put "image/gif" into tAttachment["type"]
   put "my picture" into tAttachment["name"]
   mobileComposeMail "Image Example", "you@youMailHost.com",,,, tAttachment
end mouseUp

on mouseUp
      set the vis of the templateImage to false
      mobilePickPhoto "camera"
      put the last image into tAttachment["data"]
      put "image/jpeg" into tAttachment["type"]
      put "cam picture" into tAttachment["name"]
      mobileComposeMail "Camera Example", "you@youMailHost.com",,,, tAttachment
end mouseUp

on mouseUp
   put url("binfile:" &specialFolderPath("engine") & "/LOGO.png") into tFile
   put  tFile into tAttachment["data"]
   put "image/png" into tAttachment["type"]
   put "file picture" into tAttachment["name"]
   mobileComposeMail "File Example", "you@youMailHost.com",,,, tAttachment
end mouseUp
All three methods worked.
liveCode 6.6.0 dp1, Android 2.3.5

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Sun Feb 23, 2014 10:39 pm

I am trying this but to no avail there still isn't an attchment.:
My phone is over the internet so I test it on the android devise not connect to the computer. I'm sure it is right in front of me, but I can't see it.

mobileSetKeyboardType "email"

local tSubject, tTo, tCCs, tBCCs, tBody, tAttachment
put empty into lvLaunchString  
set the defaultFolder to specialFolderPath("documents")
export snapshot from rect "0,0,200,200" of this card to FILE (specialFolderPath("documents") & "/Color.jpg") as JPEG
if the result <> empty then
    answer "ERROR:" && the result
    exit to top
end if
 put url("binfile:" &specialFolderPath("documents") & "/color.jpg") into tFile
## I've also tried without the binfile as in a previous example.
   put  tFile into tAttachment["data"]
   put "image/jpg" into tAttachment["type"]
   put "file picture" into tAttachment["name"]
   mobileComposeMail "File Example", "tyarmstead@comcast.net",,,, tAttachment

Thanks guys, I really appreciate all of your help.
Ty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Emailing an attachment

Post by Klaus » Mon Feb 24, 2014 12:21 am

Hi Ty,

not sure, but isn't the Android OS case sensitive like iOS?
If yes:
...
## put url("binfile:" &specialFolderPath("documents") & "/color.jpg") into tFile
put url("binfile:" &specialFolderPath("documents") & "/Color.jpg") into tFile
..

Best

Klaus

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

Re: Emailing an attachment

Post by Simon » Mon Feb 24, 2014 12:29 am

I'm not sure how sensitive Android is but
put "image/jpg" into tAttachment["type"]
put "image/jpeg" into tAttachment["type"]

I did use image/jpg but the attachment came in as .dat so there is something going on. image/jpeg came in with .jpg

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: Emailing an attachment

Post by tyarmsteadBUSuSfT » Mon Feb 24, 2014 1:09 am

This works for Gmail but not Comcast:
ocal tSubject, tTo, tCCs, tBCCs, tBody, tAttachment
put empty into lvLaunchString  
set the defaultFolder to specialFolderPath("documents")
export snapshot from rect "0,0,200,200" of this card to FILE (specialFolderPath("documents") & "/Color.jpg") as JPEG
if the result <> empty then
    answer "ERROR:" && the result
    exit to top
end if
put specialFolderPath("documents") & "/Color.jpg" into tFile
put  tFile into tAttachment["file"]
   put "image/jpeg" into tAttachment["type"]
   put "My Colors" into tAttachment["name"]
   mobileComposeMail "My Color Selections", "tyarmstead@comcast.net",,,, tAttachment

Thank you Klaus and Simon for all o f your help. Do you think I am doing something wrong as to why it won't work with comast.net email?
Thank you again
Ty

Post Reply

Return to “Android Deployment”