Questions tagged [mfmailcomposeviewcontroller]

The MFMailComposeViewController class provides a standard interface that manages the editing and sending of an email in iOS.

As mentioned here

The MFMailComposeViewController class provides a standard interface that manages the editing and sending of an email. You can use this view controller to display a standard email view inside your application and populate the fields of that view with initial values such as the subject, email recipients, body text, and attachments. The user can edit the initial contents you specify and choose to send the email or cancel the operation.

Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.

Before using this class, you must always check to see if the current device is configured to send email at all using the canSendMail method. If the user’s device is not set up for the delivery of email, you can notify the user or simply disable the email dispatch features in your application. You should not attempt to use this interface if the canSendMail method returns NO.

To display the view managed by this view controller, you can use any of the standard techniques for displaying view controllers. However, the most common way to present this interface is do so modally using the presentModalViewController:animated: method. Figure 1 shows the view that is displayed when you present the mail composition interface, with some of the fields already filled in. For more information on displaying the views associated with view controllers, see View Controller Programming Guide for iOS.

Important: The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol. After presenting a mail comopose view controller, your app cannot change the email content. The user can edit the content of a presented instance but the system ignores programmatic changes. If you want to set values for the content fields, do so before presenting the interface

905 questions
59
votes
13 answers

MFMailComposeViewController in iOS 7 statusbar are black

i have a feedback button in my ios 7 application with MFMailComposeViewController. After the user click this button the mailcomposer open but the statusbar changed to black. Have anybody a idea what can i do? i have this problem only with ios7. i…
NoBody
  • 719
  • 1
  • 6
  • 11
53
votes
8 answers

How to add a UIImage in MailComposer Sheet of MFMailComposeViewController

I want to insert a UIImages inside the compose sheet of an MFMailComposerViewController. Please note I don't want to attach them, but I want to place them in a table using HTML code which will be the part of the email body.
rkb
  • 10,063
  • 22
  • 70
  • 100
52
votes
4 answers

Unable to dismiss MFMailComposeViewController, delegate not called

I am calling MFMailComposeViewController from a UITableViewController. Problem is the delegate method is never called when I select Cancel or Send button in Mail compose window:…
Rod
  • 1,905
  • 3
  • 18
  • 23
42
votes
8 answers

SwiftUI: Send email

In a normal UIViewController in Swift, I use this code to send a mail. let mailComposeViewController = configuredMailComposeViewController() mailComposeViewController.navigationItem.leftBarButtonItem?.style =…
Khant Thu Linn
  • 5,035
  • 5
  • 42
  • 111
37
votes
3 answers

ios: Application tried to present a nil modal view controller on target

I am developing an application,the requirement is to open email composer on a button click of UIAlertView. message which is in message body of email is copied from UITextView. i am using following code snipt: -(void)alertView:(UIAlertView…
Bhagyashree mahajan
  • 511
  • 1
  • 6
  • 12
34
votes
3 answers

Change title color of navigation bar in MFMailComposeViewController in iOS 12 not working

How can I change the title color of UINavigationBar in MFMailComposeViewController in iOS 12? This is what I am doing: import MessageUI extension MFMailComposeViewController { open override func viewDidLoad() { super.viewDidLoad() …
pableiros
  • 10,752
  • 11
  • 79
  • 78
31
votes
5 answers

MFMailComposeViewController - iPad

I've setup a MFMailComposeViewController and it works just fine on the iPhone, but on the iPad it crashes, saying: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view…
RyanJM
  • 6,728
  • 8
  • 55
  • 89
27
votes
3 answers

Issue when using MFMailComposeViewController

I have a tricky problem. In one of my app, with over 150.000 downloads... I have a problem which seldom occurs and which I can't seem to figure out. The problem is the following: In a view where the user can share a list via email, I open the mail…
Paul Peelen
  • 9,588
  • 15
  • 82
  • 162
25
votes
4 answers

How to add a image in email body using MFMailComposeViewController

I am trying to find out the best way to add an image inside the body of the email and not as attachment in ios. 1) Apple has provided a function "addAttachment" and the doc says, to add any image in the content, we should use this function, but I…
Ranjit
  • 4,566
  • 10
  • 53
  • 118
24
votes
1 answer

Locking the Fields in MFMailComposeViewController

Is it possible to somehow lock the fields in an MFMailComposeViewController so that the body, recipients etc cannot be changed by the user? I need the e-mail the user sends to go to a particular account and the body to meet certain criteria so if…
Jack Nutkins
  • 1,545
  • 5
  • 33
  • 70
24
votes
9 answers

MFMailComposeViewController dismisses right away

The situation is the MFMailComposeViewController was going to be presented. I saw it was presented half-way done, but then it got dismissed. This is the error: _serviceViewControllerReady:error: Error Domain=_UIViewServiceInterfaceErrorDomain…
20
votes
3 answers

MFMailComposeViewController behaves differently in iOS 13 simulator and device

I'm trying to display MFMailComposeViewController in an app. if MFMailComposeViewController.canSendMail() { let mailComposeViewController = MFMailComposeViewController() mailComposeViewController.navigationBar.tintColor = .white …
Isuru
  • 27,485
  • 56
  • 174
  • 278
20
votes
1 answer

MFMessageComposeViewController alloc returns nil

In my application, MFMailComposeViewController works fine but creating a new instance of MFMessageComposeViewController fails. Here is the code for both: -( IBAction)sendSMS: (id)sender { MFMessageComposeViewController *picker =…
Lee
  • 413
  • 1
  • 4
  • 6
19
votes
6 answers

Change navigation button color in MFMailComposerViewController on iOS 7

I'm trying to change the text color for navigation buttons in a MFMailComposerViewController but it doesn't work like on iOS 6. In iOS 6 it worked with UIAppearance like this: // Navigation button UIBarButtonItem *barButton = [UIBarButtonItem…
OemerA
  • 2,502
  • 7
  • 26
  • 31
19
votes
6 answers

Changing MFMailComposeViewController's toolbar color

I'm using a tinted navigation bar and a tinted global UIToolbar in my iPhone app. In my info view, I have a button which opens a MFMailComposeViewController, and the toolbar at the top of that view (with the "cancel" and "send" button) is still…
iYassin
  • 524
  • 1
  • 10
  • 20
1
2 3
60 61