Waiting until an email has been sent on iOS? - iphone

My app allows the user to send an email through MFMailComposeViewController. While the email is being sent, I'd like to display an activity indicator. Problem is I can't find a way to know when it's been sent. The delegate is only being told whether the mail was placed in the outbox:
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
Is there any way to know whether an email has been sent on iOS?

I think you're out of luck, sort of. Once the email gets passed to the Mail app, you lose track of it, and it becomes the responsibility of the Mail app alone. And there isn't a way to even poll the Mail app to determine if an email has been sent.
But as long as the device has a network connection and the user has an email account set up, you're pretty much guaranteed the email will be sent, assuming you don't get an error returned to you. And you can always pre-check for network connectivity and email access before you attempt to present the MFMailComposeViewController.

Related

how to get email addresses from mail composer

How do you get the email addresses that the mail composer sent to was?
I tried looking at this delegate:
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError *)error
{
}
but it seems that there's no way to get the email addresses
You can't. The interface is designed such that what the user enters is not visible to you.
If you tell us what you're trying to accomplish, we may be able to suggest an alternate API or solution.
You can't get the email addresses from mail composer.
One suggestion:
If you know the name of the intended recipients, you can get the email addresses from the address book. Note that you will need to inform your users of the app's action, preferably with an option for them to proceed or cancel the action.
Please go through my same question, on which finally I concluded that There are no official Apple's API to get email addresses...
Retrieve E-mail in In-app in iPhone

How to send BCC via MFMailComposeViewController in iPhone SDK?

One part of my app sends an e-mail with an attachment. I'm using the MFMailComposeViewController class, and all is well.
I just would like to know if I can send a stealth BCC message to myself, just for statistics purposes to keep track of how many messages have been sent.
Thank you!
UPDATE: the user tc didn't understand what I was trying to accomplish. I DON'T WANT TO INVADE USER'S PRIVACY. I just need to keep track of EVENTS ON MY APP. I didn't make myself clear on what I needed.
How about the setBccRecipients: method on your instance of MFMailComposeViewController?
Depending on the content of the e-mail message being composed, you might want to re-think sending a Bcc to yourself, unbeknownst to your users... Just sayin'...
You can track if an email was sent successfully without sending yourself a bcc of the message. Check the didFinishWithResult delegate method.

MFMessageComposer iPhone,Auto Message Send

Any one know how to implement auto send message using MFMessageComposer....i mean No need of displaying The message Composer..we Have to sent the pre-defined message to a given Number..Or any other way without using MFMessageComposer..???
You can't auto-send messages with MFMessageComposer. It always displays the message to the user before sending (and rightly so).
An alternative would be to call a webservice which dispatches an email to you. Or put enough SMTP code in your app to get emails sending. You'll need your own email system for this though as you'll not be able to get the users email settings.

MessageComposeResult is sent even if the message send failed

I am using MFMessageComposeViewController to send sms within my app. Everything is correct until i try to get the result of the operation. Actually the Message sending failed as It can be seen in the SMS native app (I have no service in the sim card), but I get MessageComposeResultSent in - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result.
Have you ever gone though this? Could we get a real assert that the sms has been properly sent?
Thanks a lot.
Here is a snippet from the MessageComposeResult struct's discussion in MFMessageComposeViewController.h :
Typically MessageComposeResultSent
will be sent, but
MessageComposeResultFailed will be
sent in the case of failure. Send may
only be interpreted as a successful
queueing of the message for later
sending. The actual send will occur
when the device is able to send.

Check to see if email is enabled?

I'm working on an iPhone app that, at a certain point, will try to send an email message. If the user has an email set up, great, if not, I need to change some actions accordingly. My question is how do I check to see if the user's iPhone has an email account setup? I've looked everywhere but I can't seem to find an answer.
I'm using MFMailViewController to send the message, but I don't want to create an instance of it unless I can actually send something. Any ideas?
MFMailComposeViewController class has +canSendMail method which
Returns a Boolean indicating whether
the current device is able to send
email. (YES if the device is configured for sending email or NO if it is not.)