React Native
React Native
Save Email Attachments to Filesystem
Saves email attachments to a directory.Chilkat React Native Downloads
import { Email } from '@chilkat/react-native'
function chilkatExample() {
const email = new Email();
// Load an email object containing attachments.
// This .eml can be downloaded from:
// http://www.example-code.com/testData/HtmlEmail.eml
try {
email.loadEml('HtmlEmail.eml');
} catch {
console.log(email.lastErrorText);
return;
}
// If OverwriteExisting is turned on, files with the same
// name are overwritten. If turned off, new/unique filenames
// are automatically generated. The filenames actually saved
// are accessible via the GetAttachmentFilename method.
email.overwriteExisting = true;
// Save all attachments to the "myAttachments" subdirectory
// found under the calling process's current working directory.
// This directory is automatically created if it does not already
// exist.
try {
email.saveAllAttachments('myAttachments');
} catch {
console.log(email.lastErrorText);
return;
}
// List the attachment filenames:
for (let i = 0; i < email.numAttachments; i++) {
console.log(email.getAttachmentFilename(i));
}
}