Objective:
To Configure,compose,send an e-mail.
Approach:
1.Add the framework.
2. configure the mail account;
3.Pre-populate the fields like recipients,subjects,body-text;
Solution:
Mail functionality is not build in,so we have to import frameworks from the library.
click project navigator-->Target application-->Build Phases-->link libraries to the section-->click on + button and add UImessage Framework
import class [MessageUI/MessageUI.h] and protocol <MFMailComposeViewController> in the header file;
And create an instance for MFMailComposeViewController;
Here you set the default settings for the various fields in your email.
The available settings are:
setSubject:
setToRecipients:
setCcRecipients:
setBccRecipients:
setMessageBody:isHTML:
addAttachmentData:mimeType:fileName:
We need to determine if the user is first capable of sending e-mail, like if they have an email account set up in the mail app[configure]. Luckily for us, there is a class method that shows us just that[CanSendMail].
if the user has no email account setup,he will get an alert stating that"device not configured to send e-mail".
now set the delegate to self.
we can pre-set the recipients and set a subject,add a text to message body (optional)
Add the delegate method-didFinishWithResult ;
This delegate has only one instance method[MfMailComposerResult] and it is called when the user is ready to dismiss the mail composer.
Conclusion:
MFMailComposeViewController tutorial is done.It is a very simple view controller, but it lets you get the job done efficiently.
To Configure,compose,send an e-mail.
Approach:
1.Add the framework.
2. configure the mail account;
3.Pre-populate the fields like recipients,subjects,body-text;
Solution:
Mail functionality is not build in,so we have to import frameworks from the library.
click project navigator-->Target application-->Build Phases-->link libraries to the section-->click on + button and add UImessage Framework
import class [MessageUI/MessageUI.h] and protocol <MFMailComposeViewController> in the header file;
And create an instance for MFMailComposeViewController;
Here you set the default settings for the various fields in your email.
The available settings are:
setSubject:
setToRecipients:
setCcRecipients:
setBccRecipients:
setMessageBody:isHTML:
addAttachmentData:mimeType:fileName:
We need to determine if the user is first capable of sending e-mail, like if they have an email account set up in the mail app[configure]. Luckily for us, there is a class method that shows us just that[CanSendMail].
if the user has no email account setup,he will get an alert stating that"device not configured to send e-mail".
now set the delegate to self.
we can pre-set the recipients and set a subject,add a text to message body (optional)
Add the delegate method-didFinishWithResult ;
This delegate has only one instance method[MfMailComposerResult] and it is called when the user is ready to dismiss the mail composer.
Conclusion:
MFMailComposeViewController tutorial is done.It is a very simple view controller, but it lets you get the job done efficiently.