diff --git a/README.md b/README.md index 98b5b36..a8ba9a5 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,11 @@ var MailExampleApp = React.createClass({ subject: 'need help', recipients: ['support@example.com'], body: '', - attachmentPath: '', // The absolute path of the file from which to read data. - attachmentType: '', // Mime Type: jpg, png, doc, ppt, html, pdf - attachmentName: '', // Optional: Custom filename for attachment + attachment: { + path: '', // The absolute path of the file from which to read data. + type: '', // Mime Type: jpg, png, doc, ppt, html, pdf + name: '', // Optional: Custom filename for attachment + } }, (error, event) => { if(error) { AlertIOS.alert('Error', 'Could not send mail. Please send a mail to support@example.com'); diff --git a/RNMail/RNMail.m b/RNMail/RNMail.m index b556c20..8a027bc 100644 --- a/RNMail/RNMail.m +++ b/RNMail/RNMail.m @@ -47,10 +47,10 @@ RCT_EXPORT_METHOD(mail:(NSDictionary *)options [mail setToRecipients:recipients]; } - if (options[@"attachmentPath"] && options[@"attachmentType"]){ - NSString *attachmentPath = [RCTConvert NSString:options[@"attachmentPath"]]; - NSString *attachmentType = [RCTConvert NSString:options[@"attachmentType"]]; - NSString *attachmentName = [RCTConvert NSString:options[@"attachmentName"]]; + if (options[@"attachment"][@"path"] && options[@"attachment"][@"name"]){ + NSString *attachmentPath = [RCTConvert NSString:options[@"attachment"][@"path"]]; + NSString *attachmentType = [RCTConvert NSString:options[@"attachment"][@"type"]]; + NSString *attachmentName = [RCTConvert NSString:options[@"attachment"][@"name"]]; // Set default filename if not specificed if (!attachmentName) { @@ -62,6 +62,7 @@ RCT_EXPORT_METHOD(mail:(NSDictionary *)options // Determine the MIME type NSString *mimeType; + if ([attachmentType isEqualToString:@"jpg"]) { mimeType = @"image/jpeg"; } else if ([attachmentType isEqualToString:@"png"]) {