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?
 

cmaier

Suspended
Jul 25, 2007
25,405
33,474
California
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.
 

traviszanden

macrumors newbie
Jul 1, 2008
2
0
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.
 

traviszanden

macrumors newbie
Jul 1, 2008
2
0
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?
 

chaonic

macrumors newbie
Feb 22, 2008
12
0
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.
 

Garrett

macrumors regular
Apr 4, 2007
173
0
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"]];
 

zkmusa

macrumors regular
Jul 16, 2002
104
17
Dallas, TX
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?
 

chaonic

macrumors newbie
Feb 22, 2008
12
0
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.
 

mnkaushik

macrumors newbie
Sep 29, 2008
4
0
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.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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?
 

mnkaushik

macrumors newbie
Sep 29, 2008
4
0
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.
 

mnkaushik

macrumors newbie
Sep 29, 2008
4
0
it works in html

HTML:
<html>
<body>
<a href="mailto:k@yahoo.com?subject=subject&body=body">blah</a> 
</body>
</html>
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
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.
 

grimjim

macrumors member
May 24, 2003
75
0
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.
 

mnkaushik

macrumors newbie
Sep 29, 2008
4
0
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.
 

GregInAZ

macrumors newbie
Aug 2, 2008
23
0
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.
 

roberthuttinger

macrumors newbie
Sep 24, 2008
8
0
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.