Extract attachment from emails from a particular sender/subject

Welcome Forums General PowerShell Q&A Extract attachment from emails from a particular sender/subject

This topic contains 2 replies, has 3 voices, and was last updated by

 
Participant
3 years, 3 months ago.

  • Author
    Posts
  • #28332

    Participant
    Points: 0
    Rank: Member

    I have a report that comes with a particular subject via email to my mailbox. I need to write a script that will pull out the attachments and then put those files in a folder on the system so that other scripts can pick it up and use the files. My exchange version is 2007. I am very new to PowerShell scripting. Please help.

  • #28335

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Exchange doesn't really offer a means of doing that server side. You could potentially script against the Outlook COM object on your client, but that does get pretty complex pretty quickly.

  • #28337

    Participant
    Points: 0
    Rank: Member

    I am using the Outlook com object
    You can try something like this:

    $GetMailItems = @(
        $OutlookInbox = 6
        $Outlook = New-Object -Com Outlook.Application;
        $NameSpace = $Outlook.GetNameSpace("MAPI");
        $Inbox = $NameSpace.GetDefaultFolder($OutlookInbox))
     
           $Inbox.Items | ForEach {
            If ($_.Subject -eq "subject goes here")
            {
            Put your code to save to folder
            }}
           
    

    Like Don said it does get complex

The topic ‘Extract attachment from emails from a particular sender/subject’ is closed to new replies.