[Python] MS Graph - Application Only - Sending Emails from Shared Mailbox as Daemon

Discussão em 'Python' iniciado por Stack, Abril 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to build an app in Python which uses MS Graph to send emails from a shared mailbox, I've been focusing on the msgraph-sdk module. I need this app to run as a daemon process (no human interaction required), so figured the suitable auth-flow here is ClientSecretCredential - application rather than delegation.

    The GraphServiceClient object in msgraph-sdk gives 2 avenues to work with self.me and self.users. My understanding is I need self.users for this specific case. I do not understand the required permissions that need to be set up for an application level credential to send mail from a shared inbox.

    [​IMG]

    I have followed the tutorial @ https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=python

    using credential flow example from https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/docs/applications_samples.md

    And get:

    Error: ErrorAccessDenied Access is denied. Check credentials and try again.

    There is a part of the tutorial above to get a token, which works as expected - but I think msgraph-sdk will handle that under the hood? Is this even possible with App-Only Creds, and sending from a Shared Mailbox? Any help appreciated, thanks!

    Continue reading...

Compartilhe esta Página