How To Download Email Attachments in Office 365 Mailbox Using Python And Microsoft Graph API

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

Комментарии • 35

  • @djosue27
    @djosue27 4 месяца назад

    Absolutely amazing! Even MS Documentation doesn't illustrate this as easily

  • @motuada
    @motuada 6 месяцев назад

    It helped a lot! I had problems at the beginning because I was filtering a specific message. I removed it from the filter and it worked for all messages. I also applied the Base64 tip. Thank you for sharing.

  • @scott5957
    @scott5957 Год назад +2

    Insanely helpful video - can not thank you enough! Been banging my head against a wall for weeks trying to get this to work and this video finally made it happen. Only thing I did have to adjust at the end when you are setting the “download_attachment_endpoint” it needs (or mine did at least) a “/$value” at the end of that variable so I would get the actual file contents rather than just another JSON string. So helpful - thank you again!

    • @letsplay8389
      @letsplay8389 Год назад +2

      Thanks scott5957, this fixed the unreadable files issue others have been noting.

    • @rahulshah1408
      @rahulshah1408 7 месяцев назад

      Thank you. That was my other missing puzzle piece.

  • @CLGFM
    @CLGFM Год назад

    Finally able to read my mailbox emails, the other tutorials show you only to oauth via browser to authenticate which is useless for service scripts. Thank you.

  • @gabrielef3336
    @gabrielef3336 6 месяцев назад +2

    It's a great tutorial but in the last step you miss to convert the content of the response before witing the file.
    This could be a way (import base64):
    attachment_content = response.json()['contentBytes']
    decoded_content = base64.b64decode(attachment_content)
    # Save the file
    with open(attachment_name, 'wb') as file:
    file.write(decoded_content)
    file.close()
    Bye

    • @cmetzger4
      @cmetzger4 4 месяца назад

      Thank you so much for adding this extra bit! I was pulling my hair out

  • @svgenterprises1
    @svgenterprises1 Год назад

    This was extremely valuable in understanding how to work with the Graph API! Thank you so much for this content.

  • @sheepinriver
    @sheepinriver 9 месяцев назад

    Really helpful !! Just wondering does that Mail.Read permission allow read all user mailboxes ? That is the permission very very hard to get unless you are an IT administrator.

  • @xFree23Stylex
    @xFree23Stylex 9 месяцев назад

    Thank you for your help!

  • @rahulshah1408
    @rahulshah1408 7 месяцев назад

    Thank you for the step by step. I am new to python (former database admin with zero coding) and am having to google each line of code I am writing. This has been amazing. out of convenience, do you have a google drive or public github to access the code example?

  • @Nova04550
    @Nova04550 8 месяцев назад

    I think that's giving app permissions to every mailbox! Probably best to use delegated permissions and then authenticate on behalf of a user.

  • @TanveerKhizar
    @TanveerKhizar Год назад +1

    getting KeyError: 'value' for line 54
    for attachment in attachments['value']:

  • @magueritemichima6818
    @magueritemichima6818 9 месяцев назад

    hello Sir , great video , how can i get the code ?

  • @MrArjunrajan
    @MrArjunrajan Год назад

    I am getting an error as "/me request is only valid with delegated authentication flow." during subscription call.

  • @hemanthbanty6187
    @hemanthbanty6187 Год назад

    How to download the file to specific folder path rather than the script place.

  • @cristhiansevilla4091
    @cristhiansevilla4091 Год назад

    when I tried to run the code, this message return {'error': {'code': 'ErrorAccessDenied', 'message': 'Access is denied. Check credentials and try again.'}}

  • @srp9819
    @srp9819 Год назад

    why are you not getting a option on the browser to authorize the graphApi ,
    is there a way to by pass that , so that we can run the script any time with a scheduler , without any intervention ?

    • @bernardmwanza1628
      @bernardmwanza1628  Год назад +1

      my script does not have that browser auth thing, once you have the app secret, appclientid and tenantid hardcoded in the script, you can schedule it using windows task manager

    • @RohitKumar-yz3eo
      @RohitKumar-yz3eo Год назад

      Can you please tell how to do that

  • @JonathanDuque-d5z
    @JonathanDuque-d5z Год назад +1

    I get unreadable files

  • @momoViPRuS
    @momoViPRuS Год назад

    you WOW

  • @abhilashgaddam7836
    @abhilashgaddam7836 Год назад

    I am getting API response 403 what would I do?

    • @bernardmwanza1628
      @bernardmwanza1628  Год назад

      that is a permission problem, you have not assigned your app registration correct permission to access the resources you are requesting.

    • @juanjoseospinaduque4524
      @juanjoseospinaduque4524 Год назад

      @@bernardmwanza1628 Hello sir, at the moment i count all the permissions but im still getting this error "'message': 'Insufficient privileges to complete the operation", i need some special from de administrador o not? thx!

  • @vamsipreetham6224
    @vamsipreetham6224 Год назад

    I am getting 401 error why this is coming

    • @bernardmwanza1628
      @bernardmwanza1628  Год назад

      Your code. Is it correct

    • @vamsipreetham6224
      @vamsipreetham6224 Год назад

      The same as your followed each step carefully but getting 401 error

    • @bernardmwanza1628
      @bernardmwanza1628  Год назад

      Although 401 error is usually because of permission issue. Have u assigned and granted your app the correct application permission ?

    • @bernardmwanza1628
      @bernardmwanza1628  Год назад

      You can test the code, step by step, first very if u can get the access token, then next verify if u can get the entire json response for a particular resource instead of the custom filtered one.

    • @manishgudral2834
      @manishgudral2834 2 дня назад

      @@bernardmwanza1628 followed same steps but geeting below error
      '401, {"error":{"code":"OrganizationFromTenantGuidNotFound","message":"The tenant for tenant guid 'ce0215a9-53fd-47c2-8b2d-8aeb16e17519' does not exist.","innerError

  • @SANDRO2464
    @SANDRO2464 Год назад

    {'error': {'code': 'ErrorAccessDenied', 'message': 'Access is denied. Check credentials and try again.'

    • @Danips88
      @Danips88 9 месяцев назад

      same mistake u.u

  • @manueltraverso1634
    @manueltraverso1634 Год назад

    i get unreadable files