Mail output


I was hoping someone could help me. I am making a program in which you can enter some data and the program should mail the output of the program. My program gives the correct output. But I was wondering if there is a way to copy this output to an email?
Thanks in advance :).

I dont know how to do it directly with Codea. But you could do it indirectly:
1/ write a php web page that can receive a file and sent by mail (i dont know how to do it but i’ve seen in the php doc it is possible).
2/ make codea send the file to your web page via hhtp.request method

Ok thanks I’ll try that ! :slight_smile:

Use openurl(“mailto://user@server”)

Hello @KoBa. With the benefit of @tnlogy’s advice, this page on the Codea Wiki may help.

Thanks for the comments. But in the example you still have to write the message in the code
itself. I am trying to mail a couple of strings is this even possible with codea? Because the mailto comment does not take a string or table as an input.

.@KoBa - alternatively use the runtime and do it in Objective C. iOS6 makes it really easy to send an email, SMS, or post to twitter/facebook using the provided Activity View Controller class. For example:

        NSString *textToShare = @"Your text goes here";
        UIImage *imageToShare = [UIImage imageNamed:@"YourImage.png"];
        NSURL *urlToShare = [NSURL URLWithString:@""];
        NSArray *activityItems = @[textToShare, imageToShare, urlToShare];
        UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems: activityItems applicationActivities: nil];
        //  define the activity view completion handler
        activityVC.completionHandler = ^(NSString *activityType, BOOL completed)
            NSLog(@"Activity Type selected: %@", activityType);
            if (completed)
                NSLog(@"Selected activity was performed.");
                if (activityType == NULL)
                    NSLog(@"User dismissed the view controller without making a selection.");
                    NSLog(@"Activity was not performed.");
        //  define activity to be excluded (e.g. save to Contact and Camera Roll)
        activityVC.excludedActivityTypes = [NSArray arrayWithObjects: UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, nil];
        [self presentViewController: activityVC animated: YES completion: nil];


interesting - the pre lang = “objc” trick doesn’t seem to work.

Check out my post here:
There is some code that demonstrates URL schemes. You’ll find a scheme starting with “mailto://” which sends and email. Look here for a little more info:
Good luck!

Thanks for all the help! It works ! :smiley:

I was hoping someone could help me again. Sorry I’m totally new to Lua, so I don’t exactly know what I’m doing :P. Anyway, I managed to insert a string in my program and show this string in an email. This works fine for one string. However, when I try to do this for multiple strings it doesn’t work. I made a table of the strings and then used tostring on this table. The email shows table 0x… Is it even possible with tostring?
Thanks in advance!

Is this something like what you’re after.

function setup()
    to = ""
    cc = ""
    subject = "This is the subject"
    str1="this is the first line"
this is the second line"
this is the third line"

    create(to, cc, subject, message)

function create(to, cc, subject, body)
    url = "mailto:""?cc=""&subject="..code1(subject).."&body="..code1(body)

function code1(str)
    crlf = "%a%d-_.~"
    return string.gsub(str, "[^"..crlf.."]", code2)

function code2(c)
    return string.format ("%%%02X", string.byte(c))

Very cool @dave1707 . Thanks for sharing.

One thing I noticed with this is that leading spaces on a message line are ignored. I don’t know if there’s a way around it, or if that’s just the way it is. So you can’t format lines, they are all left justified.

@dave1707 Thanks! That’s exactly what I need =D

The meathod that @dave1707 used is called a regular expression. To learn more about it, go to

@Zoyt, Technically lua doesn’t have regular expressions built in. It uses patterns. They aren’t as powerful as regular expressions, but are usually good enough.

I’m using this code, to allow devices with iOS5 to send twits too:

- (void)sendTwit:(const char*) text withImage:(const char*) image {
    TWTweetComposeViewController *tweeter = [
       [TWTweetComposeViewController alloc]
    NSString *message = [NSString stringWithFormat:@"%s",text];
    NSString *img     = [NSString stringWithFormat:@"%s",image];
    [tweeter setInitialText:message];
    [tweeter addImage:[UIImage imageNamed:img]];
    [self.codeaViewController presentModalViewController:tweeter animated:YES];


you have to wait until Codea engine launch, there is an warning appearing if you call the function before that:

 on  whose view is not in the window hierarchy!

looks like there is no access directly to the main view that twetter needs...

I would like to know if the Codea runtime library has an call to the tweeter send button when you use the capture button (video and image)

I wonder whether there is a way to let the program send an e-mail, without opening the mail app on the iPad. I found that it could be done using smtp. . However, I’ve read that the use of sockets in Codea is not possible. I was hoping someone could help me :), sorry I’m still new to al this stuff :stuck_out_tongue:

possibly, if u use http.request parameter tables to post the data to a server which sends the data as an email