I want to send email using rightBarButtonItem without using MFMailComposerViewController.
Is It possible to send email using barButtonItem?
Any Idea how to do this?
thanx in advance.
You'll find a fantastic code sample on the accepted answer here to send a background email:
Locking the Fields in MFMailComposeViewController
All you need to do is setup your rightBarButtonItem's target to fire a method containing this email code, and then populate the message contents etc using the information you want to send.
Hope this helps!
Set an action method for the right bar button item and thus, you can make a direct call to open the email client and compose a mail.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto://testmailer#somemail.com"]];
This is just a quick fix or may be something you were looking for!
Related
I need to have my users fill out a form, and send me the information. Nothing fancy, just their name and email, and they'd be doing it willingly.
I looked into emailing the information to my account, but it seems like you have to pop the MFMailComposeViewController and let the user submit an email -- and I don't want to bother them with that.
I also tried a simple mailto url, like this:
NSString *url = #"mailto:example#example.com?&subject=Greetings from Cupertino!&body=Wish you were here!";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
But it doesn't work on my simulator, or my iPhone, which is 4s with iOS 6.
I also looked into creating a google doc, and have the application send the user's info to its URL, but I'm assuming the result would be similar to the mailto URL?
So is there a good, simple way to do it?
So is there a good, simple way to do it?
Sure -- but not using mail. Use HTTP instead, and POST the data to a web server. If you need to collect the results by mail, you could easily create an e-mail message on the server and send from there, but it seems more likely that you'll just want to add the information to a database directly.
To use HTTP, you'll create a NSURLRequest with the relevant parameters and then send it using NSURLConnection. If you don't feel like digging into the URL loading system that iOS provides, there are a number of wrapper libraries that make it even easier. But for what you want to do, using NSURLConnection directly will be pretty straightforward.
Maybe you should have a look at these links :-
How to send mail from iphone app without showing MFMailComposeViewController?
Send mail without MFMailComposeViewController
Sending Email without using MFMailComposeViewController
MFMailComposer send email without presenting view
Does anyone know if its possible and how to get the TO, FROM, CC, and BCC fields from a mail composer in a callback for the iPhone?
Using MFMailComposer.
Cannot be done. The only delegate that you find for this is
MFMailComposeViewControllerDelegate
mailComposeController:didFinishWithResult:error:
You can set it to some predefined values for once the user enters the MailComposer
By setting setToRecipients: and setCcRecipients:
But these settings are for BEFORE you give the user the control. After that you only get the above.
I am using MFMailComposeViewController for sending feedback in my app. It works fine. But the problem here is, the user can edit/delete the "to" address. I want to make it as a non-editable one. May be, the user can add some mail addresses in "to" field.
But he/she should not delete the feedback address (Here, it is "support#xxxx.com").
Here is my code...
MFMailComposeViewController *composeWindow = [[MFMailComposeViewController alloc] init];
composeWindow.mailComposeDelegate = self;
NSString *str = #"Subject of the feedback";
[composeWindow setSubject:[str stringByAppendingString:[[UIDevice currentDevice]systemVersion]]];
NSArray *toRecipients = [NSArray arrayWithObject: #"support#xxxx.com"];
[composeWindow setToRecipients:toRecipients];
[self presentModalViewController:composeWindow animated:YES];
[composeWindow release];
Thanks in Advance
Rajkanth
You can not customize MFMailComposeViewController to avoid editing. Apple forbids this, and the reason is quite simple: it is the user and not you that must decide exactly what to send, to whom etc. The same applies for the UI controller allowing to send SMS (text) messages. And, of course, Apple does not allows sending an email or SMS without explicit interaction with the user. It is the user that must validate and send the email or SMS message. The validation process include the ability to cancel the message or to change any single property at will, including the "to" recipients.
All the other answers are correct. You can not change the interface of the MFMailComposeViewController. But you have other possibilities. ;-)
Three20 SDK includes also an Mail Composer. Try it out. I think it should be that far changeable, that the "to" field is not editable anymore.
I hope my answer is helpful for you.
Sandro Meier
EDIT
Three20 SDK was discontinued a while ago. So you shouldn't use it anymore for new projects. I advise you to use NimbusKit instead. This is also recommended by the Three20 SDK team. Sadly it does not include a MailComposeViewController
From the Apple documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.
I have a situation where i need to send details entered in the UITextfields to the administrator's mail ID without opening the MFMailComposeViewController.
This is a registration part of the application,so i will ask the users to enter their personal information like name,mail ID,DOB etc.,and i want to send these information as a mail to a hard coded ID which is the administrators mail ID.
I want this mail to be sent when the register button is pressed which is kept at the bottom of the same page.
I used the MFMailComposeViewController,without displaying the Composer view by avoiding the usage of this statement in order to prevent the modal view being popped up when i hit the register button
[self presentModalViewController:picker animated:YES]; and i use the
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error by invoking it using the statement
[self mailComposeController:picker didFinishWithResult:MFMailComposeResultSent error:nil];
where picker is the object of the MFMailComposeViewController
What should i do,to implement the same?
Kindly anybody advise me on how to achieve this.
Thanks a lot to everyone.
Thats not possible with MessageUI.framework. Instead you could set up a web service which sends the mail. Your app would connect to your server and sends the mail from there.
Application is sending email by using MFMailComposeViewController, everything works just fine. However after sending email, the recipient address needs to be stored for further processing. As far as I can tell, there is no API for this.
How do I get the email address where message was sent to?
Should I subclass MFMailComposeViewController and override something? What would that be?
Could I find email address by looking at MFMailComposeViewController view hierarchy? What would I be looking for there?
Any other ideas?
Figured out a partial answer, here's the details:
http://jomnius.blogspot.com/2011/02/how-to-find-mfmailcomposeviewcontroller.html
Problems: it finds the recipient email address(es), but only if that fits in about 35 character text string. Otherwise you find only a summary string like "aaa#aaa.aa & 2 more...". So where are the actual email addresses in this case?
As an alternate UI flow -- though obviously I don't know your app, so only you'll know whether this can work -- you could instead have the user enter recipient info into a textfield and then push the mail composition viewcontroller (with the recipient(s) pre-filled).
You could even use a variation of Joe Michel's Multi-Recipient Picker library to make it feel more like the native recipient selection.