Sending an email through app; any way will do

Go To


Here is the code that I have for my cell of my UITableView:

                            forKeys:[NSArray arrayWithObjects:@"Title", @"Cells", @"Footer Title", nil]] autorelease];
[tableView1CellData addObject:sectionContainer_3];
NSMutableArray *cells_4 = [[[NSMutableArray alloc] init] autorelease];
NSDictionary *cellContainer_4_1 = [[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"Support", @"", @"", @"", @"", @"1", nil]

What would I have to add so that when the cell is tapped, it happened up a MailView in the app (preferably) but I understand that the easiest way is to just use the HTML "mailto" ? I'm brand new to Objective-C, but I am able to edit C and C++, so I think that I can work in any answer. Thanks in advance!

P.S. Posting this from iPhone (just thought of asking question) so sorry if the code isn't highlighted, but i tried to space it out.

2012-04-04 03:30
by NoName


1.Add the Message UI Framework

2.You should have registered a delegate for the UITableView. See a UITableView tutorial if needed.

3.Implement the following method:

- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 

4.Inside the method use MFMailComposeViewController to send the email. Example usage:

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO]; 
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];

Read More: How can I send mail from an iPhone application

UITableView/UITableViewCell tap event response?

2012-04-04 04:20
by Saikat
Thanks! Will read when I get home - NoName 2012-04-04 04:22


Check out the documentation on MFMailComposeViewController. You can present a mail compose view, user will fill it out and send the mail.

2012-04-04 03:34
by jer
Will check it out, thanks for the quick reply - NoName 2012-04-04 03:39
Using the code above, though, how would I do this? I'm confused by the documentation. Thanks - NoName 2012-04-04 03:51
Saikat's example shows you an example - jer 2012-04-04 20:57


And yes, you can use the mailto: URL thing... but @jer's answer is the one I would prefer to do myself, as a developer.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://"]];

(details for the above can be found at

2012-04-04 03:36
by Michael Dautermann
See comment above.. - NoName 2012-04-04 03:39
Yes, this is more clear then the documentation, but how would I connect it to thr cell - NoName 2012-04-04 03:56
the code snippet you put into your question isn't detailed enough for me to figure out where you're putting your e-mail addresses or how the table view cell is being filled out - Michael Dautermann 2012-04-04 04:03
Hmm... Ok let me see.. - NoName 2012-04-04 04:05 better - NoName 2012-04-04 04:13