PDA

View Full Version : iPhone SDK - Sending email




tnash
Jun 12, 2008, 11:28 AM
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
Jun 13, 2008, 09:12 AM
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
Jul 1, 2008, 11:45 AM
Is there a way to send an email from an iphone app and include an attachment? Please help, this must be common.

Consultant
Jul 1, 2008, 03:39 PM
No, you cannot make an app to send s-p-a-m from the iPhone.

traviszanden
Jul 1, 2008, 03:42 PM
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
Aug 6, 2008, 01:53 PM
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
Aug 6, 2008, 04:27 PM
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.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Hello"]];

zkmusa
Sep 28, 2008, 09:01 PM
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
Sep 29, 2008, 10:33 AM
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
Sep 30, 2008, 10:08 AM
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

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
Sep 30, 2008, 10:13 AM
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

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: (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAddingPercentEscapesUsingEncoding:) might be of help?

mnkaushik
Sep 30, 2008, 10:58 AM
I changed the code to


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


Now i get unsupported url.

mnkaushik
Sep 30, 2008, 11:04 AM
<html>
<body>
<a href="mailto:k@yahoo.com?subject=subject&body=body">blah</a>
</body>
</html>

Niiro13
Sep 30, 2008, 11:22 AM
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
Sep 30, 2008, 12:01 PM
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
Sep 30, 2008, 01:54 PM
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
Sep 30, 2008, 02:23 PM
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
Nov 21, 2008, 08:10 AM
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

firewood
Nov 21, 2008, 11:11 AM
You cannot try it in the simulator, to test this out you have to install it on the iPhone.


You might be able to test it on the Simulator by writing test stub apps that register themselves to handle the mailto: and tel: URLs.


.