MailSend In The iPhone

In this application we will see how to send mail from the iPhone. User just simple click in the ToRecipient , and it will take address from the addressbook. So let see how it will be worked.

Step 1: Create a View base application using template. Give the application name “MailSend”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the MailSendViewController class for you. Expand Resources and notice the template generated a separate nib, MailSendViewController.xib, for the “MailSend”.

Step 4: We need to add MessageUI Framework. After hitting the Add -> Existing Framework .. menu item an open panel will popup. Navigate to this directory.


Step 5: In the MailSendViewController.h file,we have to import MessageUI.h file and added UIButton for create a button and a method.  S make the following changes in the file.




Step 6: Double click the MailSendViewController.xib file and open it to the Interface Builder. Open the view icon and drag the Round Rect from the library and place it to the view window. Double click the button and give the name “PressButton”. Now connect  File’s Owner icon to the View icon and select view. Drag File’s Owner icon to the PressButton and select myButton. Select “PressButton” and bring up connection inspector and drag to the TouchUpInside to the File’s Owner icon and select buttonPressed: action. Now save it, close it and go back to the Xcode.

Step 7: Open the MailSendViewController.m file and make the following changes:




Step 8: Now compile and run the application in the Simulator.

You can downloaded SourceCode from here MailSend 2

Leave a Comment:

nehal11 says March 18, 2011

can i send the mail through simulator or i have to use iphone device?

Alex McPherson says April 7, 2011

Great Tut! But how do you predefine the recipient in the to field? I see you can set the Subject and the Message body but be good to be able to do this if possible?

kimziv says July 20, 2011

Thank you ! your article is very helpful for me

Dalia says December 20, 2011

thanks allot but i need to ask if i need to send page from my app i like it and i need to send it to my friend for example how i can do it ????

Bob Dawson says April 27, 2012

Can you please explain how to get this into a storyboard app?

zahid says May 26, 2013

Can I send Email to addresses which I have already save in my app in textfield?

Add Your Reply