1

I'm working on a python project to process emails as they arrive in a Microsoft inbox. Specifically, I want to set up a push subscription, receive notifications when a new email hits the inbox, and then construct and send another email based on the body of the one just received.

I'm at a loss to understand where "response.data" comes from since I can't find a reference to it anywhere in the documentation. The comment says:

When the server sends a push notification, the POST data contains a 'SendNotification' XML document. You can use exchangelib in the callback URL implementation to parse this data:

And the code in the example is:

ws = SendNotification(protocol=a.protocol)
for notification in ws.parse(response.data):
    # ws.parse() returns Notification objects
    pass

Where might I find a reference to this response.data?

Thanks in advance.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63

1 Answers1

2

response.data is just a placeholder for whatever your web server framework calls the request object. The above code snippet is meant to be used in the web server code that handles the push events that Exchange sends to the URL that you defined when you created the push notification.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
  • Erik - first, thank you for putting together this wonderful library! I appreciate your quick answer, as well. I would upvote your response, but as you can see, I'm unable. – Carlo Navici Nov 18 '21 at 16:33
  • Thanks for the kind words! The docs weren't very clear on this topic, so I added a full example of a Flask app that shows how to parse push notification messages: https://ecederstrand.github.io/exchangelib/#synchronization-subscriptions-and-notifications – Erik Cederstrand Nov 19 '21 at 07:07