Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 15, 2008, 12:02 PM   #1
Rad
macrumors regular
 
Join Date: Aug 2006
Send email with attachment [mega-merged thread]

Anyone figure out how to send an email with an attachment via an iPhone app? The simple mailto: command may work with text only, but I need to be able to send something like a photo or drawing.

Thanks!

Last edited by Blue Velvet; Nov 4, 2008 at 06:14 AM. Reason: Added [Merged] to title
Rad is offline   0 Reply With Quote
Old Jul 17, 2008, 03:27 AM   #2
asouns
macrumors member
 
Join Date: Jun 2008
same question here
asouns is offline   0 Reply With Quote
Old Jul 26, 2008, 12:01 AM   #3
DSchwartz88
macrumors 6502
 
Join Date: May 2006
Using e-mail with attachments

Hey All,

There was another question like this before, but it was never fully answered. I need to get a photo that my UIImagePickerController grabs into an e-mail, that will send to a preset address. I have two questions:

1. How do i get the e-mail message to pop up in the first place? What code would i have to implement to do so?

2. How do i insert the image that i grabed before as an attachment?

Im trying to make this very much like the MobileMe photo upload if anyone knows that.

Any help would be appreciated.

Daniel
DSchwartz88 is offline   0 Reply With Quote
Old Jul 26, 2008, 12:10 AM   #4
admanimal
macrumors 68040
 
Join Date: Apr 2005
You can open a mail message just by sending a mailto URL to openURL. You can specify the body of the message but I'm not sure if there is an official way to do attachments.
admanimal is offline   0 Reply With Quote
Old Jul 28, 2008, 03:09 PM   #5
grimjim
macrumors member
 
Join Date: May 2003
Yes, using the built-in Mail.app to send emails is really easy. You just need to pass the email's details to the app delegate via its openURL: method, and it will deal with it all for you. Here's some sample code:

Code:
UIApplication *theApplication = [UIApplication sharedApplication];

NSString *recipient = [NSString stringWithString:@"someone@somewhere.com"];
NSString *subject = [NSString stringWithString;@"The subject line"];
NSString *body = [NSString stringWithString:@"This is a really dull email. Sorry."];

NSString *s = [NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", recipient, subject, body];
NSString *mailString = [s stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:mailString];
[theApplication openURL:url];
There are a couple of caveats, though:

1. Because you are using Mail.app, which is a separate application, your own application will close. So, users will need to send the message, then press the home button and fire up your app again.

2. There is no means of adding an attachment using this method. Bummer.

How to get around it? Well, the best way to work around both the problems would actually be to implement a very simple SMTP client inside your application. You could probably find code on the web that you could adapt. It would mean that you could send the mail from within your application, so it wouldn't need to close, and that you could implement the attachment of, um attachments. Good luck!
grimjim is offline   0 Reply With Quote
Old Aug 31, 2008, 02:40 AM   #6
amanbvp
macrumors newbie
 
Join Date: Aug 2008
How to send email with attachment??

hi all,
I am searching for the solution so that my application can send an email with an attachment. I have used mailto: but it dosn't support attachment. It would be of great help if you provide me with some code or url.
amanbvp is offline   0 Reply With Quote
Old Aug 31, 2008, 02:51 AM   #7
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
As far as I can tell you can't. There is no method to send mail apart from the mailto: url. Whilst you can, in theory, pass additional mail headers into this the useful/interesting ones like Content-type are ignored. So, at least for this version of the SDK, you can only send mail with text contents.
robbieduncan is offline   0 Reply With Quote
Old Aug 31, 2008, 06:12 AM   #8
amanbvp
macrumors newbie
 
Join Date: Aug 2008
How to implement SMTP client for sending email attachment??

hi all,
I am trying to build an application which can send email with attachment and I get to know that it is not possible to do that using mailto:.Hence i am trying to implement that by developing SMTP client but i am new to the SMTP hence i don't know where to start. Pls guide me where to start and is it possible on iphone.

Thanks in advance
amanbvp is offline   0 Reply With Quote
Old Aug 31, 2008, 07:02 AM   #9
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
SMTP RFC document.

This should give you all the information you need to implement an SMTP client.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Nov 4, 2008, 05:17 AM   #10
arnieterm
macrumors regular
 
Join Date: Aug 2008
How to implement it???

As mailto does not allow you to add attachment to your email that to be sent from within your application on IPhone, I am looking for a simple SMTP mail client for IPhone.
Can anybody provide any idea how to get started??
Thanks
arnieterm is offline   0 Reply With Quote
Old Nov 4, 2008, 05:28 AM   #11
Pring
macrumors 6502
 
Join Date: Sep 2003
http://www.ietf.org/rfc/rfc2821.txt
__________________
Dardan Software
Neil Inglis' Blog
Check out Escape Pod and Alphonetic on iTunes!
Pring is offline   0 Reply With Quote
Old Nov 4, 2008, 05:40 AM   #12
CommanderData
macrumors regular
 
Join Date: Dec 2007
The RFC2821 is definitely the place to get started reading. But you may go through a lot of trouble only to find they turn you down for implementing e-mail functionality in your app. I'm only aware of one app that made it through, the one that talks to Microsoft's Hotmail/Live servers (forget the name at the moment). I think that was because it did not conflict with Apple's interests (they had no intent to ever support Hotmail/Live protocols).
CommanderData is offline   0 Reply With Quote
Old Nov 4, 2008, 12:38 PM   #13
dougdawson
macrumors member
 
Join Date: Aug 2008
Location: Austin, TX
Quote:
Originally Posted by CommanderData View Post
The RFC2821 is definitely the place to get started reading. But you may go through a lot of trouble only to find they turn you down for implementing e-mail functionality in your app. I'm only aware of one app that made it through, the one that talks to Microsoft's Hotmail/Live servers (forget the name at the moment). I think that was because it did not conflict with Apple's interests (they had no intent to ever support Hotmail/Live protocols).
I don't see anything in the NDA that prevents you from sending data via e-mail, provided that you are only using the public SDK. In fact, the networking facilities in the public SDK are very rich, and you can do a lot with them.

Where you might have a problem is with implementing YAMail.app.

Doug
dougdawson is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
General: Looking for attachment tweak for email ddublu Jailbreaks and iOS Hacks 10 Feb 13, 2014 10:20 AM
Email attachment format vjaaan OS X 10.8 Mountain Lion 3 Nov 27, 2013 12:41 AM
Reply to email with an attachment Jbenn425 iOS 7 25 Nov 22, 2013 01:44 PM
Attachment icon always indicated with email, but no attachment was ever sent JohnDohe OS X 10.8 Mountain Lion 0 Jul 17, 2013 08:09 PM
Word Email Attachment RagingGoat iPhone 0 Jul 3, 2012 02:15 PM

Forum Jump

All times are GMT -5. The time now is 03:22 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC