Send mail through code without opening MailComposer or new view - iphone

In my application i want to send mail to some one.
If i use following code new window for gets opened for mail.
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:string]];
And if i use MailComposer then same controller will shown for mail.
But i want to send mail direct from my code by opening any screen or view in my application, with the help of mail address, subject and body part.
Any help ?

download the sample code from skpsmtpmessage - Google Code and ran that.
You might require to change few things but it will work.

Hoping not to sound too advertise-y, but you can easily do this with PostageApp.
All you have to do is make an API call with your API Key, the content of your email (or a template name) and make an HTTP POST request to our API server, and ta daaaa, it sends through. We currently have a few iPhone apps doing this very thing.
As an act of fairness, you can take a look at all of the services available for such an activity and you can choose which suits your needs:
PostageApp
SendGrid
PostmarkApp
Amazon SES
(Full Disclosure: I am the Product Manager of PostageApp.)

Related

Sending mail in background

I am developing an iphone application in which i have to send a mail on custom button click and in background also it should not have user iteraction with mfmailcomposer view i.e, i dont have to show the view.
Please suggest me solution for this.
Thanks.
You could try using SKSMTPMessage:
http://code.google.com/p/skpsmtpmessage/
You won't be able to use the user's email accounts unless you ask them to provide credentials, but I've used this a few times where the sender address is not important.
The easiest solution for this problem is,
You need to create your own webservice. Pass all the details to your webservice and accordingly send email.
Details to be passed on webservice would be to/cc/bcc/subject/body etc.

Iphone send email from application

I need to be able to send emails from within the application I am developing.
Using [[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mail#mail.com"]] , the email application opens and the user can't go back to the main application.
Is there a way I can send the user back to the application after they are done sending emails ?
Many Thanks.
Have a look at MFMailComposeViewController class (requires MessageUI.framework) - it provides you with standard UI to create and send mails from inside of your application
Not that I know of, but you can include a mail composer in your application.
Look into the MFMessageComposer class and the MessageUI framework. It will allow you to show a Mail Composer view within your app.
Take a look at below URL;
http://howtomakeiphoneapps.com/2009/07/how-to-make-your-iphone-app-send-email-with-attachments/

How to activate mail application (built in in iPhone) through programming? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I send mail from an iPhone application
how to activate mail application (built in in iphone) through programming. I want to quit
my project also?
I can't really be sure by the wording of your question, but it seems like you want to send mail without leaving your application.
In the 3.0 SDK you have access to MFMailComposeViewController, which will bring up a mail window and allow you to send mail while remaining in your application.
From the Apple Docs:
The MFMailComposeViewController class provides a standard interface that manages the editing and sending an email message. 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 iPhone OS.
Something similar to:
NSString *_recipient = #"someone#email.com";
NSURL *_mailURL = [NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]];
[[UIApplication sharedApplication] openURL:_mailURL];
will open the Mail app and create a new message with the subject "My Subject" and the recipient someone#email.com. Just modify this with other headers and content to build the message you need to send.
This is how you can send mail from the iphone app.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto:biranchi#purpletalk.com?cc=youremail#gmail.com&subject=Greetings%20from%20Biranchi!&body=Wish%20you%20were%20here!"]];
If you don't want to quit your app:
iphone app send email

How do I initate an email on the iphone from a view?

I need to be able to give users the ability to call someone or email someone from a certain view in my navigation based app.
I thought I would use an action sheet with the choices and depending on the button pressed allow one or the other to be initiated (I'm simplifying a lot but ...).
I really have several questions.
Assuming this is possible to do, will my app be gone after a phone call is started?
Is there a way for me to launch/push on the stack the same "controller" and "view" that Apple uses for making calls and sending emails? Or am I going to have to code this all myself to look like their app?
I want the user to come back to the same page they were on when the email or phone call was initiated. How can I do that or is my app gone if I use their controller and nib?
Assuming it's possible to do either of these things, can I put the email address I want for a default in the to: field of the email view and if so how?
Here are the answers to your questions:
Assuming this is possible to do, will
my app be gone after a phone call is
started?
Yes.
Is there a way for me to launch/push
on the stack the same "controller"
and "view" that Apple uses for making
calls and sending emails? Or am I
going to have to code this all myself
to look like their app?
Yes. MFMailComposeViewController for Mail, and [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneText]] for a Call
I want the user to come back to the
same page they were on when the email
or phone call was initiated. How can
I do that or is my app gone if I use
their controller and nib?
For Mail this can be accomplished with MFMailComposeViewController. It's not possible for a telephone Call.
Assuming it's possible to do either
of these things, can I put the email
address I want for a default in the
to: field of the email view and if so
how?
Yes.
You can look at the sample code https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html or the tutorial http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email
unfortunately if you make a phone call then the application is terminated. For email however, I believe there is a framework or something to do that, I think it's in the messaging API, but I'm not 100% sure as whenever I use email stuff I just do a mailto: url (which closes the app)
You can not make a phone call from within you application without exiting your app.
You can send an email inside your application using MFMailComposeViewController. Your application will remain at whatever view it was at when you present the Mail Compose View Controller view. You can set all of the normal fields in an email (subject, recipients, cc, bcc, body, ect...).

Invoking Mail App on the iPhone

The application I'm writing calls a web service that sends an email to the user. After the call to the web service is complete, I would like to bring up the Mail application so the user can read the email. I know I can use mailto:, but then a new email is created for the user to compose. Is there a way to invoke the Mail application so that it starts up at the Mailboxes view, allowing the user to navigate to their inbox?
Thanks.
You can't do it. There is no functionality in the SDK to bring up another application outside of URL associations. The best you can hope for in the short term is that they create a way for you to embed an email panel into your application.