Download email attachments from a gmail account


I want to creat a script that allow me to connect to a gmail adresse in order to download mail attachments and store them is a local folder.

Do you guys have any tips, info or even a script that does this?


Thanks in advance and sorry for my english.

Well, I literally just googled your question’s header and got this.

Hello Noka40,

What did you already try?

As .NET do not contain classes to manipulate with the mailbox and read emailh, you have 2 options:

  1. Use custom email client library which implements basic email client using IMAP or POP protocols (something along those lines that Lars is suggesting)

  2. Use Google API to access the mailbox and download attachments. For more information please go here.

Hope that helps.

Hello Lars and Andy,

Thank you for your messages!

I wanted to use ImapX in order to interract with my mails but i am unable to install it or understand how to install or add it.

It seems like you need to use a dll that you download on the website but here i am with two of the different package that you can download on the website and none of them have a dll file.


Am I missing something?


I went through the whole “discussions” and “issues” topic without anything information about install or implement it to powershell.


What am i doing wrong?

There’s a Commounity Module named PSGsuite that will make this simple.

Follow the instructions there to install the module and to authorize it to interact with your GSuite. Once you have it installed you’ll need to use 2 commands.

Get-GSGmailMessage and Get-GSGmailMessageList

Get-GSGmailMessageList will let you search for email stub records and obtain an ID to be used by Get-GSGmailMessage.

Get-GSGmailMessage will let you retrieve the actual email based on the user account you want to access and the ID of the email.

All together it will look something like:

$EmailID = (Get-GSGmailMessageList -Filter { subject:"Email Subject" } | Select-Object -First 1).id

$EmailAttachment = Get-GSGmailMessage -User -Id $EmailID -SaveAttachmentsTo c:\temp

See examples here:



I think that i will aim for a linux solution.

I find out that mutt on linux is can do it, i will just have to create my own script.

I am still interested in this imapx solution.

Should try the Softaken Gmail Attachment Extractor Tool if you want to download email attachments from a Gmail account then this is the best and user user-friendly solution that can allow you to download bulk attachments at once without any changes. Here users will not face any difficulties while working with this tool that is why I want to tell users to use the tool and get a good experience with the tool. It helps to download all attachments that are saved in PDF, Doc, and XLS formats to extract attachments from your Gmail account. This is the best solution for all users who don’t have any technical skills so if you want a solution that can help to download all the emails without technical errors then should install this application on your all Windows versions. Users can download it on Windows operating systems.