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

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • In this video you will learn how to download email attachments in office365 mailbox using Microsoft graph api and python #graphapi #microsoft #office365 #python

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

  • @gabrielef3336
    @gabrielef3336 3 месяца назад +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 Месяц назад

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

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

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

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

    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 4 месяца назад

      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.

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

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

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

    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?

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

    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 6 месяцев назад

    Thank you for your help!

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

    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 11 месяцев назад +1

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

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

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

  • @MrArjunrajan
    @MrArjunrajan 10 месяцев назад

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

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

    you WOW

  • @cristhiansevilla4091
    @cristhiansevilla4091 10 месяцев назад

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

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

    I get unreadable files

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

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

  • @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

  • @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!

  • @SANDRO2464
    @SANDRO2464 11 месяцев назад

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

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

      same mistake u.u

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

    I am getting 401 error why this is coming

    • @bernardmwanza1628
      @bernardmwanza1628  11 месяцев назад

      Your code. Is it correct

    • @vamsipreetham6224
      @vamsipreetham6224 11 месяцев назад

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

    • @bernardmwanza1628
      @bernardmwanza1628  11 месяцев назад

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

    • @bernardmwanza1628
      @bernardmwanza1628  11 месяцев назад

      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.

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

    i get unreadable files