Save attachments
Leave feedback
To get and save attachments, follow these steps:
- Instantiate the Viewer object. Specify a file that contains attachments.
- Call the getAttachments method. It returns the attachment collection.
- Iterate through the collection. To save an attachment, call the saveAttachment method.
The following code snippet shows how to get and save all attachments from the MSG file:
NoteNOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.
const viewer = new groupdocs.viewer.Viewer("with_attachments.msg")
const attachments = viewer.getAttachments();
console.log('Attachments:\n');
for(let i = 0; i < attachments.size(); i++ ){
console.log(attachments.get(i).toString());
}
console.log('\nAttachments retrieved successfully.');
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.