Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time


Do you ever wish sending an email or message from within the app didn't have to go through the pain of setting up delegates and dealing with MFMailComposeViewController? Now you don't have to! DBShare is a library that makes MFMailComposeViewController and MFMessageComposeViewController problems a thing of the past.

Use the two-file source code or simply drag n' drop the static framework into your project and import the header:

#import <DBShare/DBShare.h>

Here's how to quickly send an email:

NSString *subject   = @"A Simple Email";
NSString *body      = @"Its really easy to send emails now!";
NSString *recipient = @"";

DBShareMail *mailShare = [[DBShareMail alloc] initWithController:self];
[mailShare addRecipient:recipient];
[mailShare setSubject:subject];
[mailShare setBody:body];
[mailShare setFinishedHandler:^(MFMailComposeResult result, NSError *error) {
    // This is option, but provides a handle on completion
    if (result == MFMailComposeResultSent) {
        // Message is sent
[mailShare present];

Just as easily you can send messages:

DBShareMessage *messageShare = [DBShareMessage shareFromController:self];
[messageShare setBody:body];
[messageShare setFinishedHandler:^(MessageComposeResult result) {
    // Again, this is optional
    if (result == MessageComposeResultSent) {
        // Message sent
[messageShare present];

Both DBShareMail and DBShareMessage inherit from the DBShareable object, which supports adding attachments. For both mail and message sharing, adding an attachment is as simple as:

- (void)sendImage:(UIImage *)image {
    DBShareAttachment *attachment = [DBShareAttachment attachmentWithJPEGImage:image 
    DBShareMessage *messageShare  = [DBShareMessage shareFromController:self];
    [messageShare addAttachment:attachment];
    [messageShare present];

Also, no need to keep all the different MIME types in your head. With DBMimeType enumeration, Xcode is able to provide code completion, eliminate spelling errors and allow you to quickly find the correct MIME type.

- (void)sendData:(NSData *)data {
    DBShareAttachment *attachment = [DBShareAttachment attachmentWithData:data 
                                                                     mime:DBMimeTypeAppPDF // MIME string: application/pdf 
    DBShareMail *mailShare = [DBShareMail shareFromController:self];
    [mailShare addAttachment:attachment];
    [mailShare present];


A library that makes MFMailComposeViewController and MFMessageComposeViewController problems a thing of the past



No releases published
You can’t perform that action at this time.