string replace function and sendmail

hi there

i like to open the email app from the device and give some basic data

system.openURL( "mailto:?subject=My%20Subject&body=".. datawert)

works fine....BUT

1.
when the datawert does has spaces i get "is not supported by the simulator"
on the real device it just crash.

2.
when i try to replace the space with "%20" i use

datawert = string.gsub( datawert, " ", "%20" )
but here i get the problem % is a function so i get:

invalid capture index
stack traceback:
[C]: ?
[C]: in function 'gsub'

now what :)
first how to replace " " with %20
and second maybe solves itself by that :)

chris

ok as usual five mins later.. i have one answer

%%20 would do the job (just add an additional %)

ok.. now i can replace " " with "%20"

but finally i also have several linebreaks "\n" in my code and while

doing
system.openURL( "mailto:?subject=MyDays%20History%20&body=".. datawert)

i get

WARNING: url( mailto:?subject=test&body=2011-09-07%20day1
2011-09-06%20day2
2011-09-05%20day3
) is not supported by the simulator

and on the device the screen comes just black... and thats it

but somehow i need that \n to have a line break...
any idea how to make line breaks for the email body without \n ??

(in my native android app that works just fine)

:) and also last point is solved

datawert = string.gsub( datawert, "\n", "%%0A" )

so if anyone want to send "\n" by email... just use %0A

greets
chris

Nice! Thanks for posting follow ups. I'm sure others will find this useful in the future :)

views:1289 update:2011/9/26 8:07:09
corona forums © 2003-2011