Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tnash

macrumors newbie
Original poster
Jun 12, 2008
3
0
Anyone know if it is possible to send and email from within a custom app on the iPhone (i.e. using the sdk to call the iPhone email application or some other means).

You can interact with the contacts and calendar, can you interact with email?
 
Anyone know if it is possible to send and email from within a custom app on the iPhone (i.e. using the sdk to call the iPhone email application or some other means).

You can interact with the contacts and calendar, can you interact with email?

yes, you create a mailto: url (which can include subject and body) and launch it.
 
Send email with attachment

Is there a way to send an email from an iphone app and include an attachment? Please help, this must be common.
 
I'm not trying to send s-p-a-m I'm trying to create an legit iPhone app for download through the app store. Anyone have real solutions?
 
I'm resurrecting this post because, like tnash, I would like my app to launch Mail so that an email can be sent... but I'm not sure how to do that.
 
I'm resurrecting this post because, like tnash, I would like my app to launch Mail so that an email can be sent... but I'm not sure how to do that.

Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Hello"]];
 
Applications like Safari and the Photo app launch a sliding new message panel when you want to send an email. Is this possible to set up using the third party SDK rather than launching the entire Mail application?
 
Applications like Safari and the Photo app launch a sliding new message panel when you want to send an email. Is this possible to set up using the third party SDK rather than launching the entire Mail application?

I'm not aware of a way. I don't think that's possible yet.
 
Does this work in the simulator

I tired using mailto url but the mail application did not launch in the iPhone simulator. I added a button to my view and in the delegate method for touch up inside i had the following code

Code:
NSURL *url = [[NSURL alloc] initWithString:@"mailto:k@yahoo.com?subject=This is my subject&body=this is the body"];
[[UIApplication sharedApplication] openURL:url];


This did not launch the mail application. Earlier i had the wrong url for mailto , i got an alert saying could not process url. But now nothing happens.
 
I tired using mailto url but the mail application did not launch in the iPhone simulator. I added a button to my view and in the delegate method for touch up inside i had the following code

Code:
NSURL *url = [[NSURL alloc] initWithString:@"mailto:k@yahoo.com?subject=This is my subject&body=this is the body"];
[[UIApplication sharedApplication] openURL:url];


This did not launch the mail application. Earlier i had the wrong url for mailto , i got an alert saying could not process url. But now nothing happens.


That doesn't look like a valid URL to me: you can't have spaces in URLs. I think you might well want to encode it. Perhaps stringByAddingPercentEscapesUsingEncoding: might be of help?
 
Still not working

I changed the code to

Code:
NSURL *url = [[NSURL alloc] initWithString:@"mailto:k@yahoo.com?subject=subject&body=body"];
[[UIApplication sharedApplication] openURL:url];

Now i get unsupported url.
 
it works in html

HTML:
<html>
<body>
<a href="mailto:k@yahoo.com?subject=subject&body=body">blah</a> 
</body>
</html>
 
I've used the same code and got it to work on the device. I was under the impression that it didn't work in the simulator because there is no mail app on it.
 
I've used the same code and got it to work on the device. I was under the impression that it didn't work in the simulator because there is no mail app on it.

You're absolutely correct. The simulator will always complain that it doesn't know what to do with a mailto: URL. If you think you've got it right, the only way to test it for sure is on a device.
 
What happens to ur app

I dont have access to a device currently. I was trying to find out whether my application will shutdown if i call the email app using mailto url. Same for calling a phone number does it shutdown my app if i use tel url to call a number.
 
I dont have access to a device currently. I was trying to find out whether my application will shutdown if i call the email app using mailto url. Same for calling a phone number does it shutdown my app if i use tel url to call a number.

We open the email app from our app using a mailto url and it does shut it down. The user has to re-launch our app after they've finished sending the email.
 
Answer to: 'error when launching'

You cannot try it in the simulator, to test this out you have to install it on the iPhone. If you get the message, "could not process request" its probably the issue.

Install on the iPhone and there you go!

bo

wyzfam :apple: tMiMP :apple: tCiMP :apple: My Baby Signs
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.