React Native
React Native
Add File Attachments to an Email
Demonstrates how to add one or more file attachments to an email.Chilkat React Native Downloads
import { Email } from '@chilkat/react-native'
function chilkatExample() {
const email = new Email();
email.subject = 'This is a test';
email.body = 'This is a test';
email.from = 'support@chilkatsoft.com';
email.addTo('Chilkat Admin', 'admin@chilkatsoft.com');
// To add file attachments to an email, call AddFileAttachment
// once for each file to be attached. The method returns
// the content-type of the attachment if successful, otherwise
// returns cknull
let contentType = '';
try {
contentType = email.addFileAttachment('something.pdf');
} catch {
console.log(email.lastErrorText);
return;
}
try {
contentType = email.addFileAttachment('something.xml');
} catch {
console.log(email.lastErrorText);
return;
}
try {
contentType = email.addFileAttachment('something.zip');
} catch {
console.log(email.lastErrorText);
return;
}
try {
email.saveEml('email.eml');
} catch {
console.log(email.lastErrorText);
return;
}
console.log('Saved EML!');
}