Sending invitation from contact list in iPhone - iphone

In an app I have to send invite through contact details in iPhone. I know that contact details can be fetch by ABPeoplePickerNavigationController.And on a button action, I am able to get contact details. Now, on selecting any contact name I should be able to send a mail to that contact user.
Now, please share some information.

Check if the contact has email if it does then,
NSString *subject = [NSString stringWithFormat:#"Subject"];
NSString *mail = [NSString stringWithFormat:#"contact#mail.com"];
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:#"mailto:?to=%#&subject=%#",
[mail stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
[[UIApplication sharedApplication] openURL:url];
FYI : If the user hasn't set the email for particular contact then you won't be able to send email anyway :)

Related

UIMessage "sending direct mail"

I am developing an exam app. After the completion of the exam, if the person presses the done button, the results will be sent directly to the person's email.
I know how to use the MessageUI framework, but i don't want to get any compose view - instead it should go directly to the concern email.
Does anybody know if this is possible?
Thanks in advance.
For example syntax :
NSString *msgToSend = #"This is an Example Message to be send";
NSString *urlStr = [NSString stringWithFormat:#"www.home.com?method=aMethodName&msg=%#",msgToSend]; //here msg is a parameter of your url string
NSLog(#"%#",urlStr);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Hope it gives you an idea...
This is possible but for this you need a webservice which will send the mail.

Direct Email to userid

I'm trying to send an email to a X person with some details in the app.
I'm using the following code. I don't want to use the MessageUI because I want to send mail directly without showing the mail composer.
NSString *url = [NSString stringWithFormat:#"mailto:pradeep#gmail.com?&subject=Results&body=Check Out your Results here=%#",score];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
But it fails with EXEC_BAD_ACCESS. Can anyone let me know how to solve it?
You can't send the mail without the mail composer. The way you are trying to do it will open the mail app and show the user the mail filed in with all the detail give in the mail link.
The only way to do what you want it to either have a webservice which handels the mail of implement SMTP in your app. You will need ask to user for there SMTP setting so a webservice might be the best way.

i want to open from my aap. "settings >> mail >> add account " (the add account page) is it possible.?

In my app, if the user has not configured their E-mail account on their iPhone, then when the user opens the application, it will ask for e-mail configuration (means the app redirects to "settings >> mail >> add account " add account page),
How can I do that?
I searched and found one similar question in stack overflow but it was not helpful.
just like this so question
just see the official sample code.Here is the link:SampleCode
find the launchMailAppOnDevice() function.
// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
NSString *recipients = #"mailto:first#example.com?cc=second#example.com,third#example.com&subject=Hello from California!";
NSString *body = #"&body=It is raining in sunny California!";
NSString *email = [NSString stringWithFormat:#"%#%#", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
It was useful for me. Hope it can help you.

Sending an image in a faceless email

I am trying to send a faceless email (sending an email without showing the interface), using the code below.
I also want to attach an image to this email.
Is this possible?
- (void) sendEmailTo:(NSString *)toStr withSubject:(NSString *)subjectStr withBody:(NSString *)bodyStr
{
NSString *emailString=[[NSString alloc] initWithFormat:#"mailto:?to=%#&subject=%#&body=%#",
[toStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[subjectStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[bodyStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];
[emailString release];
}
You are unable to send faceless emails using the built-in emailer.
However you should be able to roll your own emailer using parts from email frameworks like for instance Pantomime

how to send e-mail without MFMailComposeViewController in iOS?

How to redirect to mail application from iPhone application?
I have seen in Stack Overflow like MailComposerViewController.
They are sending email from within the iPhone application. But I want to quit project and redirect it to in-built Mail app Which is in iPhone?
How can I do this?
I have tried the following. Are there any frameworks required for this?
- (IBAction)ddd:(id)sender
{
NSString *_recipient = #"someone#email.com";
NSURL *_mailURL = [NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]];
[[UIApplication sharedApplication] openURL:_mailURL];
}
No, there are plenty of stackoverflow posts on how to send e-mail without MFMailComposeViewController. In fact, there was at least one response to your request 16 hours earlier that would quit your app and start Mail
Here's how I do it in my apps, copied exactly as it is:
-(IBAction) mailForHelp:(id)sender
{
NSString *urlStr = [NSString stringWithFormat:#"mailto:info#BitsOnTheGo.com?subject=NumMemorize Question"];
NSURL* mailURL = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL: mailURL];
}