For instance, you could set up a python script that is connected to the Outlook REST APIs. Get the access token by following the instruction in the above website and use the access token to login. You could set time intervals to re-check your message/mail box and process those data. There could be functions/parameters in the api which allows you to receive update automatically every n seconds (I have not looked into the details yet). Write your own process function to process data to mine the data for your own usage.
import time
def main():
data = get_my_messages(<your_access_token>)
time.sleep(5)
process(data)
main()
Such examples python code could be found in the website above.
def get_my_messages(access_token):
get_messages_url = graph_endpoint.format('/me/mailfolders/inbox/messages')
# Use OData query parameters to control the results
# - Only first 10 results returned
# - Only return the ReceivedDateTime, Subject, and From fields
# - Sort the results by the ReceivedDateTime field in descending order
query_parameters = {'$top': '10',
'$select': 'receivedDateTime,subject,from',
'$orderby': 'receivedDateTime DESC'}
r = make_api_call('GET', get_messages_url, access_token, parameters = query_parameters)
if (r.status_code == requests.codes.ok):
return r.json()
else:
return "{0}: {1}".format(r.status_code, r.text)