Email Data

Discussion in 'iOS Programming' started by MiniMacLean, Nov 6, 2008.

  1. macrumors newbie

    Joined:
    Mar 9, 2008
    #1
    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:
    Code:
    [[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

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2
    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.:

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

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

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

    Joined:
    Mar 9, 2008
    #3
    thanks alot works great!! :)

    anyone know how to make the navigation bar thin?
     

Share This Page