Download attachment from custom folders on Outlook

Describe the issue/error/question

I need to download attachments (it is going to be a pdf) from emails that will come to some custom folders on Outlook. But my Problem is that when I use the getAll: Folders node I only get the standard folders. Is there any way to get the custom ones?

Please share the workflow

Information on your n8n setup

  • n8n version:
    0.193.5
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:
    Docker

Hi @Daniel_Lopez, I am very sorry to hear you’re having trouble here.

I just ran the below example workflow against my own account, and it returned a non-standard folder I’ve just created (you can see how the default folders are all in German for me):

Can you confirm whether you’re using the business version of MS365 (this is what I have used here) or a private Outlook.com account?

Also, could you share a screenshot showing your folder structure with me? I’d like to understand whether it’s a top level folder you’re looking for or a child folder of any existing folder.

1 Like

Thank you for your quick reply. To be fair I don’t know what happened but when taking screenshots for you and running the flow again it worked :sweat_smile: so I think I don’t have any issues lol

1 Like

Morning @MutedJam ! I have another question on this node… why do all the folders have the same id? Because what I need is to download the attachments from the custom folders that I marked on the screenshot yesterday :skull_and_crossbones:

1 Like

That’s a bloody good question and I don’t have the answer to that unfortunately. Either the API used by this node returns useless IDs or we made a mistake parsing the response. I’ll block some time this afternoon for a closer look.

1 Like

Looks like it’s neither @Daniel_Lopez and the data shown had us both fooled. I’ve added some additional logging to see the actual request made by n8n and the respective response.

The response coming from MS looks like so (before n8n would do anything with it):

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('a033b303-8ef0-47db-855d-e2d55a518ee2')/mailFolders",
  "value": [
    {
      "id": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAFKAAA=",
      "displayName": "Archiv",
      "parentFolderId": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAEIAAA=",
      "childFolderCount": 0,
      "unreadItemCount": 0,
      "totalItemCount": 360,
      "sizeInBytes": 19400828,
      "isHidden": false
    },
    {
      "id": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAEPAAA=",
      "displayName": "EntwĂĽrfe",
      "parentFolderId": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAEIAAA=",
      "childFolderCount": 0,
      "unreadItemCount": 0,
      "totalItemCount": 0,
      "sizeInBytes": 0,
      "isHidden": false
    },
    {
      "id": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAEKAAA=",
      "displayName": "Gelöschte Elemente",
      "parentFolderId": "AAMkAGUwNmViYmUzLTZlOTEtNDZiMy05ZGFiLTBiNTdlODgwMTU0ZQAuAAAAAACa8igOa-hdQIIifMy-dIUxAQBJDX6_c8NpSJ-YGd6-0K4RAAAAAAEIAAA=",
      "childFolderCount": 0,
      "unreadItemCount": 0,
      "totalItemCount": 498,
      "sizeInBytes": 50702755,
      "isHidden": false
    },
(...)

Just like in the UI the IDs look identical, but they actually differ very slightly:

This also seems to be the case for you:

That’s really hard to see though so this had me confused all day :see_no_evil:

1 Like

Oh my gosh, you are right… that is indeed a very small difference :face_with_spiral_eyes: then I have another question… as from my workflow from the beginning on the second node I wanted to get the messages from one of these folders and I was going to use an expression for the folder id:

But when checking for the output data of the previous node where we were getting the folders, we only are getting the first folder with its id:

Sorry for disturbing you that much haha and thanks for your help

Hi @Daniel_Lopez, this is expected. The expression editor will use the first item only for the preview from your screenshot, but when actually executing your workflow, the node should run for each incoming item.

Should I then use the IF Node if I only want to use the custom folders?

That’s up to you, the IF node should do the job just fine.

Personally, I’d probably store the IDs of the folders in my workflow (so I don’t have to look them up repeatedly or need to update my workflow in case someone renames the folder). Perhaps something like this:

Ohh okay I see.

I think as you say that is better than looking every time for the folders.

Thanks a lot for your help

No problem, you are most welcome!

I think I have one last question… I am using a node to get attachments from the message but I am not getting the id of the attachment:

The id I need to download the attachment (the id you see is the message id):

Hi @Daniel_Lopez, not sure I understand your problem.

The “Get Many” operation for the “Message Attachment” resource would return the ID of each attachment. You can then download the attachments like so:

The IDs are once again very similar but not quite the same for me.

1 Like

Yessir, I used the id from the wrong node that’s why it didn’t work :zipper_mouth_face:

Thanks a lot again and now the flow is finished

1 Like

Excellent, many thanks for confirming!

1 Like

I have the best solution for you if you want to download attachments from custom folders on Outlook you should try the ToolsBaer Outlook Attachment Extractor Tool with this tool you will not face any technical errors. This application can work with all versions of Outlook OST and PST files. Install it now on Windows OS and Get a free trial to examine its features.

Use the Softaken Outlook PST Extractor Tool to download attachments from the custom folder on Outlook because this tool has a special option for adding the custom folder through this you can add any format of attachments like JPG, PNG, XLS, DOC, CSV, and PDF, like this you can download other formats as well. Users can work with Outlook on all versions of OST and PST files without restriction and if you want to learn more about its features then you can Install this tool free on Windows operating systems.