Page 1 of 1

Emailing an attachment

Posted: Sat Feb 22, 2014 2:23 pm
by tyarmsteadBUSuSfT
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 2:34 pm
by Klaus
Hi Ty,

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


Best

Klaus

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 3:22 pm
by tyarmsteadBUSuSfT
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 3:28 pm
by Klaus
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 3:38 pm
by tyarmsteadBUSuSfT
It is with 6.6.0-dp|build
Should I file a bug report?

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 3:57 pm
by Klaus
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 7:31 pm
by tyarmsteadBUSuSfT
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 7:39 pm
by Klaus
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

Re: Emailing an attachment

Posted: Sat Feb 22, 2014 9:04 pm
by tyarmsteadBUSuSfT
Thanks Klaus,
But it is stopping at the export snapshot line.
Ty

Re: Emailing an attachment

Posted: Sun Feb 23, 2014 12:19 am
by Klaus
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

Re: Emailing an attachment

Posted: Sun Feb 23, 2014 5:48 am
by Simon
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

Re: Emailing an attachment

Posted: Sun Feb 23, 2014 10:39 pm
by tyarmsteadBUSuSfT
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

Re: Emailing an attachment

Posted: Mon Feb 24, 2014 12:21 am
by Klaus
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

Re: Emailing an attachment

Posted: Mon Feb 24, 2014 12:29 am
by Simon
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

Re: Emailing an attachment

Posted: Mon Feb 24, 2014 1:09 am
by tyarmsteadBUSuSfT
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