转自:http://blog.csdn.net/iefreer/article/details/4740517
3.0以前使用mailto URL,但是会退出当前应用程序
3.0后Apple提供了MessageUI framework可以在我们的应用程序内实现邮件发送功能,代码示范参见:
https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html
可以添加附件和以HTML格式发送邮件。
如果想要在邮件中添加URL如:http://ditu.at/tinyurl
可以如下编码:
// Fill out the email body text
NSString *emailBody = [[NSString alloc]init];
NSArray *arSubviews = [shareView subviews];
UITextField *tvMessage = [arSubviews objectAtIndex:4];
emailBody = [NSString stringWithFormat:@"%@,%@ <a href = '%@'>%@</a>", tvMessage.text,NSLocalizedString(@"FOR_DETAILS",@""),
[self.tinyURLList objectAtIndex:0],[self.tinyURLList objectAtIndex:0]];
NSString *pageLink = @"http://mugunthkumar.com/yourapp";
NSString *iTunesLink = @"http://link-to-yourapp";
NSString *emailBody =
[NSString stringWithFormat:@"%@/n/n<h3>Sent from <a href = '%@'>your app</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", @"test url", pageLink, iTunesLink];
[mailPicker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:mailPicker animated:YES];