0

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.

cduck
  • 2,691
  • 6
  • 29
  • 35

2 Answers2

6

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 Jan 17 '10 at 07:30
  • cduck: MFMailComposeViewController has a method `- (void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename` – Kenny Winker Jan 17 '10 at 07:35
  • Mailcore (more specifically, CTCoreMessage) doesn't have built-in attachment support as far as I know. –  Jan 17 '10 at 07:44
2

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: Open Source Cocoa/Cocoa-Touch POP3/SMTP library?

Community
  • 1
  • 1
Kenny Winker
  • 11,919
  • 7
  • 56
  • 78