Writing to a Text file then email the file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Writing to a Text file then email the file

Post by trags3 » Thu May 08, 2014 7:46 pm

I am trying to write to a text file and then email that file.
Here is some representative code

put " " & fld "lftp1" of card 3 & fld"tspr1"of card 3 & fld "totalproceeds" of card 3 into line 43 of URL (specialfolderpath("documents") & "/sellnet.txt")
close file URL (specialfolderpath("documents") & "/sellnet.txt")
put file URL(specialfolderpath("documents") & "/sellnet.txt") into tattachment
go card 4
mobilecomposemail "Net Sheet", "tom@jatyindustries.com", , ,"Please see the attched File", attachment

I don't know if the file is created or not but I do know that it is not being sent.

This is a standalone app on android.

Thanks for your help.

Tom

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Writing to a Text file then email the file

Post by Klaus » Thu May 08, 2014 8:42 pm

Hi Tom,

almost :D
...
## Save some typing and put path to file into a variable first:
put specialfolderpath("documents") & "/sellnet.txt" into tFile

## I hope you have a good reason for "put ... into line 43 of ...) 8)
put (" " & fld "lftp1" of card 3 & fld "tspr1" of card 3 & fld "totalproceeds" of card 3) into line 43 of URL("file:" & tFile)

## Only close if you previously OPENed the file!
## This is not neccessary with the URL syntax!
## close file URL (specialfolderpath("documents") & "/sellnet.txt")
put URL("file:" & tFile) into tAttachment
go card 4
mobilecomposemail "Net Sheet", "tom@jatyindustries.com", , ,"Please see the attched File", Attachment
...

Best

Klaus

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Writing to a Text file then email the file

Post by trags3 » Thu May 08, 2014 8:52 pm

Klaus wrote:Hi Tom,

almost :D
...
## Save some typing and put path to file into a variable first:
put specialfolderpath("documents") & "/sellnet.txt" into tFile

## I hope you have a good reason for "put ... into line 43 of ...) 8)
put (" " & fld "lftp1" of card 3 & fld "tspr1" of card 3 & fld "totalproceeds" of card 3) into line 43 of URL("file:" & tFile)

## Only close if you previously OPENed the file!
## This is not neccessary with the URL syntax!
## close file URL (specialfolderpath("documents") & "/sellnet.txt")
put URL("file:" & tFile) into tAttachment
go card 4
mobilecomposemail "Net Sheet", "tom@jatyindustries.com", , ,"Please see the attched File", Attachment
...

Best

Klaus
Hi Klaus
I am putting text into the file 1 line at a time to get it formatted correctly.
My example only showed the last line.
I'll give this a try. I thought I was close but....

Tom

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Writing to a Text file then email the file

Post by trags3 » Thu May 08, 2014 10:08 pm

Klaus,
I'm not quite sure why but the attachment isn't in the email. Everything else works.
I checked to make sure the sellnet.txt file exists by:

answer (specialfolderpath("documents") & "/sellnet.txt")

and the path shows up.

Yet no attachment.

Ideas?

Tom

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Writing to a Text file then email the file

Post by SparkOut » Thu May 08, 2014 10:28 pm

That will just answer what you literally told it to, it's not checking to see if the file exists.

If there is a file (thepath) then... Is the form you need to test for a file's existence.

I imagine the file is there regardless. Check the line where the mobilecomposemail statement resides. I think there is a typo in the snippet from Klaus. Attachment should be tAttachment shouldn't it?

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Writing to a Text file then email the file

Post by trags3 » Thu May 08, 2014 11:08 pm

SparkOut wrote:That will just answer what you literally told it to, it's not checking to see if the file exists.

If there is a file (thepath) then... Is the form you need to test for a file's existence.

I imagine the file is there regardless. Check the line where the mobilecomposemail statement resides. I think there is a typo in the snippet from Klaus. Attachment should be tAttachment shouldn't it?
Yes I corrected the typo, But it still doesn't work.
I tried the:

if there is a file (tfile) then answer tfile
else
endif
And the file shows up
and I tried

if there is a file (tfile) then answer tfile
else
endif
and the file shows up.
Still no email attachment

Thanks,
Tom

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

Re: Writing to a Text file then email the file

Post by Simon » Fri May 09, 2014 2:49 am

Hi Tom,
Haven't checked out your code but only gMail currently works with attachments, there is a bug report.
I tested with images and attachments do work with Android gMail.

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

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Writing to a Text file then email the file

Post by trags3 » Fri May 09, 2014 2:55 am

Simon wrote:Hi Tom,
Haven't checked out your code but only gMail currently works with attachments, there is a bug report.
I tested with images and attachments do work with Android gMail.

Simon
Thanks Simon.

That explains a lot.

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

Re: Writing to a Text file then email the file

Post by Simon » Fri May 09, 2014 3:08 am

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

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

Re: Writing to a Text file then email the file

Post by Simon » Tue May 13, 2014 8:34 am

Hi Tom,
I don't know if you already have but can you add your notes/experience/device/email client or really just anything to the bug report.
http://quality.runrev.com/show_bug.cgi?id=11895
They are looking into this right now and the more information we can provide the faster they'll find a solution.

Yeah, if it were iPhone they'd already have a solution :x

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

Post Reply