Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email from Cocoa

How can I send an email from a Cocoa app without using any email clients ? I have NSURL but it opens up an email client. I would like to send the email without this happening.

like image 579
Lenny Magico Avatar asked Mar 28 '11 15:03

Lenny Magico


1 Answers

Those response are outdated Mac OS X 10.8 and more you should use NSSharingService

NSArray *shareItems=@[body,imageA,imageB];
NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
service.delegate = self;
service.recipients=@[@"[email protected]"];
service.subject= [ NSString stringWithFormat:@"%@ %@",NSLocalizedString(@"SLYRunner console",nil),currentDate];
[service performWithItems:shareItems];

The sharing service documentation page

like image 89
bpds Avatar answered Nov 10 '22 17:11

bpds