Iterate through the collection and get Parser object for each item.
The following example shows how to extract emails from Exchange Server:
// Create the connection object for Exchange Web Services protocol
EmailConnectionconnection=newEmailEwsConnection("https://outlook.office365.com/ews/exchange.asmx","email@server","password");// Create an instance of Parser class to extract emails from the remote server
try(Parserparser=newParser(connection)){// Check if container extraction is supported
if(!parser.getFeatures().isContainer()){System.out.println("Container extraction isn't supported.");return;}// Extract email messages from the server
Iterable<ContainerItem>emails=parser.getContainer();// Iterate over attachments
for(ContainerItemitem:emails){// Create an instance of Parser class for email message
try(ParseremailParser=item.openParser()){// Extract the email text
try(TextReaderreader=emailParser.getText()){// Print the email text
System.out.println(reader==null?"Text extraction isn't supported.":reader.readToEnd());}}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.
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.