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

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

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 :slight_smile:
first how to replace " " with %20
and second maybe solves itself by that :slight_smile:

chris

[import]uid: 4795 topic_id: 14876 reply_id: 314876[/import]

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)

[import]uid: 4795 topic_id: 14876 reply_id: 54924[/import]

:slight_smile: 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
[import]uid: 4795 topic_id: 14876 reply_id: 54925[/import]

Nice! Thanks for posting follow ups. I’m sure others will find this useful in the future :slight_smile: [import]uid: 52491 topic_id: 14876 reply_id: 55041[/import]