Download email attachments from a gmail account

Welcome Forums General PowerShell Q&A Download email attachments from a gmail account

Viewing 5 reply threads
  • Author
    Posts
    • #237352
      Participant
      Topics: 6
      Replies: 18
      Points: 71
      Rank: Member

      Hello,

      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.

    • #237373
      Participant
      Topics: 12
      Replies: 38
      Points: 261
      Helping Hand
      Rank: Contributor

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

    • #237502
      Participant
      Topics: 0
      Replies: 37
      Points: 372
      Helping Hand
      Rank: Contributor

      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.

    • #237532
      Participant
      Topics: 6
      Replies: 18
      Points: 71
      Rank: Member

      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?

    • #237598
      Participant
      Topics: 6
      Replies: 18
      Points: 71
      Rank: Member

      Hello,

       

      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.

    • #237571
      Participant
      Topics: 6
      Replies: 15
      Points: 141
      Rank: Participant

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

      https://psgsuite.io/Initial%20Setup/

      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:

      See examples here:
      https://psgsuite.io/Function%20Help/Gmail/Get-GSGmailMessageList/

      https://psgsuite.io/Function%20Help/Gmail/Get-GSGmailMessage/

Viewing 5 reply threads
  • You must be logged in to reply to this topic.