1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Email Data

Discussion in 'iPhone/iPad Programming' started by MiniMacLean, Nov 6, 2008.

  1. macrumors newbie

    I have an application,
    It auto rotates,
    It has a UITextView,
    It has a UINavigationBar,
    It has a UIBarButtonItem,

    The UIBarButtonItem is linked to a function which is:
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Text&body=[B][COLOR="Red"]Text[/COLOR][/B]"]];
    However I want the body of the email to be the contents on the UITextView but dont have a clue how to do this,

    can i do it with the same function as this now or do i have to use a different function?


    also i would like to know how to make the UINavigationBar thin when the application is auto rotated
  2. macrumors 6502a

    You can access the content of a UITextView via its text property (docs: https://developer.apple.com/iphone/...ce/UITextView_Class/Reference/UITextView.html) i.e.:

    NSString *body = textView.text;
    Before you can put it in a mailto to link, you need to escape it, i.e.:

    body = [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
    And then you can simply construct the mailto link and insert it into the line of code you provided:

    NSString *mailto = [NSString stringWithFormat:@"mailto:email@email.com?subject=Text&body=%@", body];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailto]];
  3. macrumors newbie

    thanks alot works great!! :)

    anyone know how to make the navigation bar thin?

Share This Page