Extract attachment from emails from a particular sender/subject

This topic contains 2 replies, has 3 voices, and was last updated by  Wilfredo Perez 2 years, 9 months ago.

  • Author
  • #28332

    Bindushree L

    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

    Don Jones

    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

    Wilfredo Perez

    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

You must be logged in to reply to this topic.