In-App email message body help

Discussion in 'iOS Programming' started by uaecasher, Apr 12, 2010.

  1. uaecasher macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    hello,

    I want to include a link in message body of an in-app email, I've got the in-app to work but not sure how to add the link generated by the app in message body, I save the link in an NSString called "returnString"

    my body message is set to nil at the moment.

    Code:
    
    [mailComposer setSubject:nil];
    
    
    Thanks :)
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    What, exactly and in detail, is not working or confusing when you use the clearly documented setMessageBody:isHTML: method?
     
  3. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #3
    I have an image uploading app, I want the body to have the link of the image after it was uploaded, I checked the HTML option but I think that option would work with a fixed link right?

    sorry if I wasn't clear in initial message, thank you.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Yes, if you set the message body to syntactically correct HTML then it should work. The best way to find out it is to try it.
     
  5. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #5
    I really tried to do it but not really sure how, could you please help me out? maybe give me a hint or something :D

    Thanks
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Usual rules: post your code.
     
  7. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #7
    using this tutorial: http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/

    I used the NSString *returnString in setMessagebody

    Code:
    
    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
    
    .......
    
    -(IBAction)sendMail {
    	
    	MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
    	mailComposer.mailComposeDelegate = self;
    	
    	if ([MFMailComposeViewController canSendMail]) {
    		
    		[mailComposer setToRecipients:nil];
    		[mailComposer setSubject:nil];
    		[mailComposer setMessageBody:returnString isHTML:YES];
    		
    		[self presentModalViewController:mailComposer animated:YES];
    		
    	}
    }
    
    
    
    I get 'returnString' undeclared
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    Where, exactly, is return string declared (I assume it's not just floating in space as in your code. If it's an instance variable of the object declare it as such in the .h file. If that's part of another method then obviously it's not going to be in scope where you are trying to use it.
     
  9. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #9
    it's part of another method, I though this might be the problem. how could I save it to something accessible by another method?
     
  10. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #10
    Either pass it to the method as a parameter or make it an instance variable of the class.
     
  11. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #11
    Okay, thanks for the info, gotta go check my Obj-c book to see how to make it an instance variable of the class :)
     
  12. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #12
    Code:
    @interface MyClass
    {
    Type* myInstanceVariable;
    }
    @end
    
    It's important to learn the correct names/terminology as well as the syntax...
     
  13. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK

Share This Page