views:

579

answers:

2

I want my app to be able to send an email with attachment to a hard-coded recipient with no user input required, unlike the MessageUI framework.

Is there any way to do this? Any example code would be appreciated.

Thanks in advance.

+6  A: 

Apple doesn't give you a way to do this. You'll have to write your own IMAP library or use a 3rd-party library (Mailcore is good).

How can I attach a file to the email?
cduck
cduck: MFMailComposeViewController has a method `- (void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename`
Kenny Winker
Mailcore (more specifically, CTCoreMessage) doesn't have built-in attachment support as far as I know.
+2  A: 

As Saurabh said, there is no low level mail library. I would look for an SMTP library, rather than an IMAP one, because you don't need to get mail, just sent it.

Attachments can be done with MFMailComposeViewController's via -(void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename

Which I believe simply base64 encodes the data, and attached a mime type header and footer.

Check out this question for lots on the topic: http://stackoverflow.com/questions/740939/open-source-cocoa-cocoa-touch-pop3-smtp-library

Kenny Winker