Download email attachment with a subject line using Powershell

mishan1134 1 Reputation point
2021-02-05T12:02:07.193+00:00

Hi,

Need some help with a powershell script which I can use to download attachments in a mail and save to a particular folder.
I have 3 email coming to me daily, which have a specific subject line, and each of them have an attachment.
I need to save it into a predefined folder.
Would it be possible to define a folder based on the Subject line?

Thanks in advance for the help.

Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,939 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,403 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. vTech 6 Reputation points
    2021-02-07T22:26:58.53+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. Jade Liang-MSFT 9,956 Reputation points Microsoft Employee
    2021-02-08T07:41:08.867+00:00

    Hi @mishan1134 ,
    Agree with vTech, we could save the specific attachment with a specific attachment via use outlook rules and run a script(Rules>Manage rules and alerts>New rules>Apply rule on the message I receive>with specific word in subject>run a script).

    If you still need related information about powershell, I have researched a lot about it and found a similar thread, which provides some reference code, please kindly check if it could also work for you.

    Hope your issue would be resolved soon and if your issue has any update, please feel free to post back.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.