1

I need to send email programmatically in iphone os 2.0.

some where i found

NSString *url = [NSString stringWithString: @"mailto:foo@example.com?cc=bar@example.com&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!"];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];

is this is code work on iphone os 2.0.

similarly I need to send sms in iphone 2.0 and make a call.

I found it is not possible in sending sms in iphone 2.0 and making call.

Is there any third party tools to send sms?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
Mahesh Babu
  • 3,209
  • 9
  • 45
  • 94
  • 1
    A quick search of this site will answer your question, it has been asked many, many times, always with the same answer: http://stackoverflow.com/search?q=[iphone]+send+sms – Matthew Frederick Jan 04 '11 at 10:43
  • It looks like the best option will alienate all of MaheshBabu's pre iOS4.0 users. – ingh.am Jan 04 '11 at 10:49

2 Answers2

3

You cannot send an SMS programmatically under any version of iOS, ever.

Under iOS 2 and 3 you can present the SMS app with a sms:// link and you can include the number to send it to, but that's it. You cannot include the message body, and no matter what you can never send the message. The user must send the message.

Under iOS 4 you can present a view controller with the number to send it to and the message body using MFMessageComposeViewController, but you still cannot send the message. The user can tap the send button, but that's it.

Apple specifically protects iPhone owners from SMS messages being sent without their knowledge and approval.

Matthew Frederick
  • 22,017
  • 10
  • 68
  • 96
0

To make a call from your app call this line:

[[UIApplication application] openURL:[NSURL URLWithString:@"tel://THE_TELEPHONE_NUMBER"]];

Remember this won't work in the Simulator and you may want to check if the device is an iPod or iPad before calling! I also tend to show a UIAlertView asking the user if they actually want to call the number as this can be very annoying if they didn't mean it.

For SMS: Check out this How to programmatically send SMS on the iPhone?

Community
  • 1
  • 1
ingh.am
  • 24,319
  • 41
  • 126
  • 176
  • i think it is not work in iphone 2.0 it works after 3.2...some one has told here http://stackoverflow.com/questions/4582327/how-to-make-a-call-programmatically – Mahesh Babu Jan 04 '11 at 10:30
  • Hmm, well I haven't used iphone 2.0 for a very long time. I can guarantee that I had openURL working with 2.2.1 but I do not know before this. – ingh.am Jan 04 '11 at 10:32
  • Why are you using 2.0 anyway? Do you plan on distributing this as I'm pretty sure you won't get very far down the official route. Even Ad Hoc distribution (I think) has to be built with 3.0 as a minimum. – ingh.am Jan 04 '11 at 10:34
  • i need to support all the oses that available in market,that's the reason – Mahesh Babu Jan 04 '11 at 10:36
  • Well unless there is a specific reason you want to support iPhone os 2.0 you might as well drop it. How do you even plan to build with support for it? With the latest versions of the SDK (4.0 onwards) you cannot even build the deployment target for 2.0 - afaik 3.0 is the earliest a new build can support. – ingh.am Jan 04 '11 at 10:46
  • Also, I don't have any stats to back this up, but I would say that most users are at OS 3.0 and above. – ingh.am Jan 04 '11 at 10:46