There are plenty of examples to be found if you look for them. You can use the Outlook COM object or you can use Exchange Web Services to do this.
372093-script-to-extract-all-senders-and-subjects-of-messages-in-a-specified-mailbox
372093-script-to-extract-all-senders-and-subjects-of-messages-in-a-specified-mailbox
viewthread.cfm