Page 1 of 1

Writing to a Text file then email the file

Posted: Thu May 08, 2014 7:46 pm
by trags3
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

Re: Writing to a Text file then email the file

Posted: Thu May 08, 2014 8:42 pm
by Klaus
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

Re: Writing to a Text file then email the file

Posted: Thu May 08, 2014 8:52 pm
by trags3
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

Re: Writing to a Text file then email the file

Posted: Thu May 08, 2014 10:08 pm
by trags3
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

Re: Writing to a Text file then email the file

Posted: Thu May 08, 2014 10:28 pm
by SparkOut
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?

Re: Writing to a Text file then email the file

Posted: Thu May 08, 2014 11:08 pm
by trags3
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

Re: Writing to a Text file then email the file

Posted: Fri May 09, 2014 2:49 am
by Simon
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

Re: Writing to a Text file then email the file

Posted: Fri May 09, 2014 2:55 am
by trags3
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.

Re: Writing to a Text file then email the file

Posted: Fri May 09, 2014 3:08 am
by Simon

Re: Writing to a Text file then email the file

Posted: Tue May 13, 2014 8:34 am
by Simon
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