Hi. I want to send emails with attachments from my iphone application with custom UI. What can i use for this?
UPD: maybe it's possible to use some smtp library for this task? What can you advice?
Hi. I want to send emails with attachments from my iphone application with custom UI. What can i use for this?
UPD: maybe it's possible to use some smtp library for this task? What can you advice?
You will need to compile in your own SMTP server, there are a few online that work. This is a pile of hurt. Just use the iPhones Message Composer which is standard. Unless you are building a email spam client this wont really work.
you need to do the following first add a framework by right clicking on project. Add -> Existing Framework -> library/frameworks/MessageUI.framework
then in ViewController.h file
@interface ViewController : UIViewController { //....yor variables }
in ViewController.m file
(void)viewDidLoad {
[super viewDidLoad];
self.title = @"Sample Email Application"; // title of navigation bar
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(composeMail:)] autorelease]; // for adding a compose button //in navigation bar. //...your code }
-(void) composeMail: (id) sender{ MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init]; picker.mailComposeDelegate = self;
[[picker navigationBar] setTintColor:[UIColor blackColor]];
[picker setSubject:@"Sample Email Application"];
[picker setMessageBody:[NSString stringWithFormat:@"Visit for more help %@. ",@"http://google.com"] isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
The open source three20
framework has designed it's own Mail capabilities via TTMessageController
which mimics the original Mail app..You can use that as a starting point and then simply modify the UI of it to your needs.
E-mailing attachments is another story though...
More information: http://www.three20.info/overview