Email Data

Discussion in 'iOS Development' started by DotSlashSlash, Nov 6, 2008.

  1. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    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. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Code:
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:email@email.com?subject=Text&body=%@", yourTextView.text]]];
  3. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    when pressing the button it opens up the mail application however the body feild is now empty, do i have to update the UITextView or anything?
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Of course. If you don't have anything in the text view, then the text view has no text. Nothing will be sent to the email.
  5. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    no the text view has text in when i open the app and type in it and press the mail button it doesnt show anything
  6. e3m

    e3m New Member

    Joined:
    Sep 29, 2007
    Messages:
    8
    Likes Received:
    0
    thanks for the tip, but my problem is that you can only send one word to main at a time.
  7. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
  8. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    That's the same exact thing I just told you, only it's expanded to three lines of code instead of one.
  9. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    i dont know why but adding
    Code:
    stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
    makes it work for me.

    anyway, i was wondering, how you would put more than one string of text in an email, i tried

    Code:
    NSString *mailto = [NSString stringWithFormat:@"mailto:?body=%@%@", text1, text2];
    and it just displays the first string twice like text1text1

    i think its something with the %@ but i dunno what the right thing is, any one help?
  10. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    complete guess but have you tries %@text1%@text2 sorry it was a complete guess it probably wont work please post back

Share This Page