PDaria
PDaria

Reputation: 457

Mail send framework for iphone

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?

Upvotes: 2

Views: 2050

Answers (4)

Himanshu A Jadav
Himanshu A Jadav

Reputation: 2306

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

#import <MessageUI/MessageUI.h>

@interface ViewController : UIViewController  <UITextFieldDelegate, MFMailComposeViewControllerDelegate>{
//....yor variables
}

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];
}



- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
[controller dismissModalViewControllerAnimated:YES];
}

Upvotes: 2

Stephan Leroux
Stephan Leroux

Reputation: 761

If you want to send email without using the native mail composer UI and without setting up your own SMTP server, you can check out PostageApp (http://postageapp.com/). There's an iOS / Mac API wrapper that lets you send email through the API. https://github.com/postageapp/postageapp-objc

(Disclosure: I work for PostageApp and developed the plugin.)

Upvotes: 1

iwasrobbed
iwasrobbed

Reputation: 46703

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

Upvotes: 0

John Ballinger
John Ballinger

Reputation: 7550

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.

Upvotes: 1

Related Questions