Download Outlook Email Attachments Using Microsoft Graph API In Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ย. 2024

ความคิดเห็น • 68

  • @albinrdz1432
    @albinrdz1432 ปีที่แล้ว +5

    to those who have problems with the downloaded files, 1kb or if it is corrupt file, the problem is Jie forgot to add ,headers=headers in line 17.
    attachment_content = requests.get(
    GRAPH_API_ENDPOINT + '/me/messages/{0}/attachments/{1}/$value'.format(message_id, attachment_id),
    headers=headers
    )

  • @ashwinks2965
    @ashwinks2965 2 ปีที่แล้ว

    Thanks a lot for the Video👏. Very Useful one. But I am getting exception.
    Exception: {'error': {'code': 'Request_BadRequest', 'message': "Unrecognized query argument specified: 'top,select,filter,count'.

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      As the error states, your query is incorrect.

  • @sarveshsinha8188
    @sarveshsinha8188 2 ปีที่แล้ว

    Thanks for the video it really helped alot. I am looking for solution to mark mail as read after reading it using graph api.

  • @tridibbiswas3361
    @tridibbiswas3361 2 ปีที่แล้ว

    Thank you for the video. What’s the theme and font you are using.

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      Hey Tridib, glad the video helped. I am using VS Code with Dark Pro color theme with my own color theme customization.

  • @adoruizq
    @adoruizq ปีที่แล้ว

    How can we set up the orderby param? For example, if I want to sort emails by receivedDateTime desc, how would I set up the string corresponding to that param?

  • @somitmitra823
    @somitmitra823 ปีที่แล้ว

    what is the maximum size of attachment that we can fetch from the Graph API endpoint ?

  • @clawlan
    @clawlan ปีที่แล้ว

    Thanks for this. I am getting the following error in the flow variable: "No tenant-identifying information found in either the request or implied by any provided credentials". I'm assuming this means it wants me to pass the tenantID but I don't think generate_access_token() is set up for that. Any ideas?

    • @CLGFM
      @CLGFM ปีที่แล้ว

      I got the same response, did you manage to find a fix since?

  • @jonathanduque594
    @jonathanduque594 ปีที่แล้ว +1

    the attachments remain as corrupted files, I can't find a solution to this, did it happen to you?

    • @albinrdz1432
      @albinrdz1432 ปีที่แล้ว

      to those who have problems with the downloaded files, 1kb or if it is corrupt file, the problem is Jie forgot to add ,headers=headers in line 17.
      attachment_content = requests.get(
      GRAPH_API_ENDPOINT + '/me/messages/{0}/attachments/{1}/$value'.format(message_id, attachment_id),
      headers=headers
      )

  • @TT-hl3sm
    @TT-hl3sm 2 ปีที่แล้ว +1

    Hi Jenn, thank you very much for the video. I was able to generate a token and download files with different extensions, however, when you open the downloaded attachments they only have the following: {"error":{"code":"InvalidAuthenticationToken","message":"Access token is empty."}. Any help would be appreciated!

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      Without looking at your script, I can only guess there could be a typo somewhere.

    • @TT-hl3sm
      @TT-hl3sm 2 ปีที่แล้ว

      @@jiejenn Thank you very much for the response! To make sure that there are no typos I tried copying code from your links above. The only change I made is APP_ID and the folder where the attachments need to be saved. I am getting the same error- "Access token is empty." The attachments are saved with different extensions, but they only contain the same error message. Thank you, Jie Jenn!

    • @rohanm9662
      @rohanm9662 2 ปีที่แล้ว +2

      @@TT-hl3sm try adding ,headers=headers in line 17

    • @TT-hl3sm
      @TT-hl3sm 2 ปีที่แล้ว

      @@rohanm9662 Thank you, Rohan. I actually tried the proposed modification. August 23, 2022 I was getting an error ":{"code":"BadRequest","message":"Resource not found for the segment 'messages'."} , September 5, 2022 error ":{"code":"ResourceNotFound","message":"Invalid version: v1.0me"}.

    • @justinrajr9807
      @justinrajr9807 ปีที่แล้ว

      @@TT-hl3sm same problem for me i also can't open the attachments if u clear this say how to do

  • @xolaninqubezelo3091
    @xolaninqubezelo3091 ปีที่แล้ว

    How can I extract an email body and subject line from a specific user?

  • @gautami5934
    @gautami5934 2 ปีที่แล้ว

    Thanks a lot for the video. Can you please help me to export contact photos. I want to use Patch or Put request.

  • @vickey8709
    @vickey8709 2 ปีที่แล้ว

    Hi Jenn,
    Thanks it's very helpful!
    I want to download attachments from a specific sender with some specific subject line. After that want to upload those attachments to aws s3 buckets without downloading into local.. could please help me to update with the modified code. Would be helpful.
    Thank you

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      Hi Vickey, your request is quite specific. I would post your question on Stack Overflow for assistance.

    • @vickey8709
      @vickey8709 2 ปีที่แล้ว

      @@jiejenn Thank you

    • @bharathikannan5772
      @bharathikannan5772 2 ปีที่แล้ว

      @@vickey8709 Hi Vickey, did you get the solution for this

    • @manojm2099
      @manojm2099 2 ปีที่แล้ว

      Hi Vickey, Were you able to find the solution? If yes, could you please share me that

  • @rohitpagar17
    @rohitpagar17 6 หลายเดือนก่อน

    Could you please make video on retrieve MS Teams chat in python?

    • @jiejenn
      @jiejenn  6 หลายเดือนก่อน +1

      I will look into it.

    • @rohitpagar17
      @rohitpagar17 6 หลายเดือนก่อน

      @@jiejenn Thank please make it as soon as possible it will really helpful..there is not a single video on TH-cam on this topic.
      With the chat data we can perform various tasks with python libraries 🔥

  • @manojm2099
    @manojm2099 ปีที่แล้ว

    Thanks Jie Jenn
    I was able to download the attachments but it seems their size is 1kb and not able to open them

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Hard to tell without looking at your script.

    • @AIgineer
      @AIgineer ปีที่แล้ว

      I had same problem as you and debugged to find out that the response code for attachment_content was 401 which is unauthorized response although I already authenticated. However I forgot to add in the headers (where the access_token is stored) in the get request. It worked after adding headers = headers in the get request

    • @srp9819
      @srp9819 ปีที่แล้ว

      same with me , all files are of 1 kb , and its opening for me.

    • @albinrdz1432
      @albinrdz1432 ปีที่แล้ว

      to those who have problems with the downloaded files, 1kb or if it is corrupt file, the problem is Jie forgot to add ,headers=headers in line 17.
      attachment_content = requests.get(
      GRAPH_API_ENDPOINT + '/me/messages/{0}/attachments/{1}/$value'.format(message_id, attachment_id),
      headers=headers
      )

  • @vignesh8483
    @vignesh8483 ปีที่แล้ว

    Can the graph API help in extracting the whole email as a html file

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Sure. response can be in either HTML or text format.

    • @vignesh8483
      @vignesh8483 ปีที่แล้ว

      @@jiejenn thanks;

  • @amalthachappilly9186
    @amalthachappilly9186 ปีที่แล้ว

    Is there a way to download .eml attachment using graph API ?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      You should be able to down any file format.

  • @Iva60571
    @Iva60571 2 ปีที่แล้ว

    Great video, thank you! However, the link to your site is not working :-(

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว +1

      Thanks for letting me know. I must've changed something on my hosting yesterday. Fixing it right now...

  • @parvindersingh
    @parvindersingh 2 ปีที่แล้ว

    Which user's mailbox is this app id linked to?

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      To whichever account you authenticated.

  • @misterjasoom515
    @misterjasoom515 ปีที่แล้ว

    hi i want to specific an email address and download the pdf attachment can i use the same cod ?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      If you want to use specific email address, replace /me/ with /users/.

    • @misterjasoom515
      @misterjasoom515 ปีที่แล้ว

      @@jiejenn thnx but if u can help im getting this error {"error":{"code":"InvalidAuthenticationToken","message":"Access token is empty.","innerError"

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      You might have to Google it.

    • @misterjasoom515
      @misterjasoom515 ปีที่แล้ว

      @@jiejenn thnx for your help

  • @NP-zg3hq
    @NP-zg3hq ปีที่แล้ว

    Can we download the messege itself in .msg format?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Msg file is specific to Windows Outlook. Are you on a Windows PC?

    • @NP-zg3hq
      @NP-zg3hq ปีที่แล้ว

      @@jiejenn yes, outlook with office 365 account

    • @jiejenn
      @jiejenn  ปีที่แล้ว +1

      @@NP-zg3hq Because msg is specific to Windows Outlook application, you will have to use VBA to export emails as msg files.

  • @sebastianeyzaguirre8394
    @sebastianeyzaguirre8394 2 ปีที่แล้ว

    Does it still hold if an email has multiple attachments?

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      What do you mean? The video is showing how to download multiple attachments already.

  • @davidbeiler6364
    @davidbeiler6364 ปีที่แล้ว

    how do you get the message ID?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      You can use the message list method.

  • @TmanD54
    @TmanD54 ปีที่แล้ว

    how do i find emails with specific text?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Not sure if I understand your question.

    • @TmanD54
      @TmanD54 ปีที่แล้ว

      @@jiejenn searching the inbox for specific words in the subject line

    • @cgnature
      @cgnature ปีที่แล้ว

      how can i make the script download attachment only from a specific sender@@jiejenn

    • @GraceZhang-oo5sf
      @GraceZhang-oo5sf ปีที่แล้ว

      I can download my outlook attachments with specific subject and then rewrite the attachment file name with current day, but i not sure can do this in api@@TmanD54

  • @jiejenn
    @jiejenn  2 ปีที่แล้ว +1

    Don't know where your app id is? please refer to this video th-cam.com/video/1Jyd7SA-0kI/w-d-xo.html for instruction.

    • @Eagervul
      @Eagervul ปีที่แล้ว

      Haha, thanks! Was asking God where that came from, but it seems like it was a scroll away! :)))

  • @chandrasekharmedisetti6608
    @chandrasekharmedisetti6608 ปีที่แล้ว

    How to install ms_graph?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      You will have to create the module yourself. Source code is in the description.

  • @maribkhan3099
    @maribkhan3099 2 ปีที่แล้ว

    from where to get app id?

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      You can refer to this video th-cam.com/video/1Jyd7SA-0kI/w-d-xo.html