Send email from your App Part 1



Similar documents
2. Create the User Interface: Open ViewController.xib or MainStoryBoard.storyboard by double clicking it.

INTRODUCTION TO IOS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 13 02/22/2011

ITP 342 Mobile App Dev. Alerts

Yahoo Terminology

Managing Contacts in Outlook

Law School Computing Services User Memo

Automatic Integration into Olympus Transcription Via FTP

Amy wants to use her to view some photos her friend Sandy sent, from her vacation to Washington DC.

Praktikum Entwicklung von Mediensystemen mit

Outlook Web App OWA Quick Guide. Getting you up to speed quickly.

Organizing and Managing

Outlook Web App (OWA) To create a new message:

Shasta College SharePoint Tutorial. Create an HTML Form

Managing Mailbox Space and Personal Folders

Outlook Quick Steps & Rules

When you have decided what to include in your signature, you will need to open the signatures and stationery dialogue box:

Basics. For more information on the Library and programs, visit BCPLS 08/10/2010 PEMA

Gmail: Sending, replying, attachments, and printing

OUTLOOK GETTING STARTED

Microsoft Outlook Sorting, searching and filtering s. Sorting your messages

Microsoft Outlook 2003 Quick How-to Guide

Tutorial: ios OData Application Development with REST Services. Sybase Unwired Platform 2.2 SP04

Filtering with Microsoft Outlook

Why should I back up my certificate? How do I create a backup copy of my certificate?

Adding the BU IMAP Inbox 1. Along the left side of the screen, there is a Mail column. Look for the All Mail Folders section.

Advanced Outlook Tutorials

ing a large amount of recipients

Life after Microsoft Outlook Google Apps

LinkPoint Connect for Salesforce Tutorial Lotus Notes Edition

Managing Online and Offline Archives in Outlook

Student Office 365 Outlook Web App OWA Quick Guide. Getting you up to speed quickly.

Quick Guide on How to Clean up your Mailbox

How To Use Webmail. Guiding you through the Universities online

- Training. Getting Started with Outlook Information Technology Services - Training The University of Texas at Austin

ios Development Tutorial Nikhil Yadav CSE 40816/60816: Pervasive Health 09/09/2011

Creating Rules in Outlook

Section 9. Topics Covered. Using the Out of Office Assistant Working offline Time Required: 30 Mins

Xcode Application note

Lab: Data Backup and Recovery in Windows XP

An Introduction to Modern Software Development Tools Creating A Simple GUI-Based Tool Appleʼs XCode Version 3.2.6

emarketing Manual- Creating a New

How to Use Windows Firewall With User Account Control (UAC)

How to use the VCCS Student System

Importing Contacts to Outlook

Once you ve signed up, all you ll have to do is sign in. To sign in key in your address and password.

Saving GroupWise as Text Files

10/28/2013. Partners Zixmail Web Portal. Provider Training. Let s Get Started!

Windows Live Mail Setup Guide

Microsoft Office 365 includes the entire Office Suite (Word, Excel, PowerPoint, Access, Publisher, Lync, Outlook, etc ) and an OneDrive account.


Division of Student Affairs Quota Practices / Guidelines

Microsoft Outlook Quick Reference Sheet

How To Use Exhange On Outlook On A Pc Or Macintosh Outlook 2007 On Your Pc Or Ipad (For Windows Xp) On Your Ipad Or Ipa (For Your Windows Xp). (For A Macintosh) On A

Microsoft Office 365 Outlook Web App (OWA)

1. Open Thunderbird. If the Import Wizard window opens, select Don t import anything and click Next and go to step 3.

Lab - Data Backup and Recovery in Windows XP

Microsoft Outlook 2010 Hints & Tips

IT Quick Reference Guides Sharing, Delegation and Multiple Accounts

Life after Lotus Notes

Word 2010: Mail Merge to with Attachments

How Do I Create a Sent-mail Filter for my Outlook IMAP Account?

A guide to sorting, deleting, archiving and moving s in Outlook 2010

Configuring your client to connect to your Exchange mailbox

Office365 at Triton College

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

FC Manager Instructions

Sharing Files with HomeGroup

Why the need for set of rules in Microsoft Outlook?

How To Use Outlook On A Pc Or Macbook With A Pc (For A Pc) Or Macintosh (For An Ipo) With A Macbook Or Ipo With A Ipo (For Pc) With An Outlook (For Macbook

introduction to emarketing

Getting Started (direct link to Lighthouse Community

Microsoft Outlook Tips & Tricks

Sample- for evaluation purposes only! Advanced Outlook. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

Outlook Web App McKinney ISD 5/27/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

Outlook XP Only

How to make sure you receive all s from the University of Edinburgh

Transitioning Your School Account

Outlook 2013 ~ e Mail Quick Tips

Outlook . User Guide IS TRAINING CENTER. 833 Chestnut St, Suite 600. Philadelphia, PA

Use Office 365 on your iphone or ipad

Retention Information Messages automatically age out of your mailbox

Microsoft Outlook 2013 Workshop

Outlook 2010 Essentials

Outlook 2013 ~ Advanced

Barracuda Spam Firewall

Copy Documents from your Computer (H Drive) to a Flash Drive

U.S. Bank Secure Mail

GroupWise Training How to deal with Junk Mail

Exchange Account (Outlook) Mail Cleanup

Inventory Manager. Getting started Usage and general How-To

AUTO ARCHIVING. December, 6 th 2005

Encryption Guide version 1.2, by Thomas Reed

Transcription:

Send email from your App Part 1 This is a short and simple tutorial that will demonstrate how to develop an app that sends an email from within the app. Step 1: Create a Single View Application and name it SendMail as follows: (Note: You can use the Story board if you want but this is just a single view application.) Step 2: The first thing we will have to do is add the MessageUI.framework to our project. Right click on the main project folder at the top of the Project Explorer window. Click on the Build Phases tab on the top and open up the Link Binary With Libraries category.

Click on the very little + (plus symbol) at the bottom of the category window. Find the MessageUi.framework and click add.

The finished list looks like this: Step 4: Create the User Interface to look like this. Basically add 3 Text Fields and 1 Button so it looks something like this: Step 4: Open ViewController.h. First we need to import the MessageUI class by adding the header to the top of ViewController.h as follows: #import <MessageUI/MessageUI.h> We also need to add the <MFMailComposeViewControllerDelegate> protocol, like this:

@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate> Now we need to wire the button and the three Text Fields as follows: @property (weak, nonatomic) IBOutlet UITextField *to; @property (weak, nonatomic) IBOutlet UITextField *subject; @property (weak, nonatomic) IBOutlet UITextField *message; - (IBAction)send:(UIButton *)sender; We can now add a method to get rid of the keyboard when the user is done typing into each of the Text Fields. Wire one of the Text Field s, Did End on Exit to an IBOutlet called finished. The following method looks like this: - (IBAction)finished:(UITextField *)sender; Wire the other two Did End on Exit events to this method as well so all three Text Fields will work with this one method. After doing this you can save and close this file. Step 5: Open ViewController.m Add the line to synthesize the properties as follows: @synthesize to, subject, message; Step 6: Implement the reignfirstresponder for the text fields. Add the code to the finished method to clean up our UI after the user is done typing into the text fields. This doesn t have anything to do with emailing it s just used to close the keyboard after a user enters text into a Text Field. - (IBAction)finished:(UITextField *)sender [sender resignfirstresponder]; Step 7: Add the send method implementation.

All the work is done by the MFMailComposeViewController. First we check to see if the phone can send mail. If it can we create an instance of the MFMailComposeViewController and use it to set the subject, the body and the recipients of the email. settorecipients takes an array as an argument so we need to put our to text into an array. After setting up the email we present the email view the present ModalViewController. The finished method looks like this: - (IBAction)send:(UIButton *)sender NSLog(@"Inside send method"); if ([MFMailComposeViewController cansendmail]) // set the send To address NSMutableArray *recipients = [[NSMutableArray alloc] initwithcapacity:1]; [recipients addobject:to.text]; MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailcomposedelegate = self; [controller setsubject:subject.text]; [controller setmessagebody:message.text ishtml:no]; [controller settorecipients:recipients]; [self presentmodalviewcontroller:controller animated:yes]; else UIAlertView *alert = [[UIAlertView alloc] initwithtitle:@"alert" message:@"your device is not set up for email." delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alert show];

Step 8: In order to get rid of the email view after sending we need to implement the mailcomposecontroller:didfinishwithresult:error method. In this method we can handle if the user selected to cancel sending the email and decided to delete or save it. We won t do anything but send an alert in the event that the email failed after the user tried to send it. Add the following method to ViewController.m: - (void)mailcomposecontroller:(mfmailcomposeviewcontroller*)contr oller didfinishwithresult:(mfmailcomposeresult)result error:(nserror*)error switch (result) case MFMailComposeResultCancelled: case MFMailComposeResultSaved: case MFMailComposeResultSent: case MFMailComposeResultFailed: default: UIAlertView *alert = [[UIAlertView alloc] initwithtitle:@"email" message:@"email Failed" delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alert show];

[self becomefirstresponder]; [self dismissmodalviewcontrolleranimated:yes]; Step 9: Build and Run and check it out. Of course the simulator isn t going to be able to send a real email. You ll have to run it on a phone to do that. You should see the following results: When you press the Send Email button you will see: After you press Send you will be returned back to your app.