mirror of
https://github.com/status-im/react-native-mail.git
synced 2026-08-31 03:31:13 +00:00
Changes based on comments
This commit is contained in:
@@ -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');
|
||||
|
||||
+5
-4
@@ -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"]) {
|
||||
|
||||
Reference in New Issue
Block a user