Author Posts

April 17, 2015 at 3:21 pm

I am trying to retrieve data from an Inbox subfolder and I am having a brain block.

Can someone please help me with this?

The folder is just one level below my Outlook Inbox and I need to parse information from the email items in this subfolder. Basically, the subfolder's name is "Microsoft Project and Visio Installs Inventory Notices" and I would like to have a script that can read each mail item and output the info like this:

XX number of Visio Pro Installs
XX number of Visio Standard Installs
XX number of Project Pro Installs
XX number of Project Standard Installs

For some reason I just cannot get my head wrapped around it.

This is what I have so far, but I am needing to tweak this a bit to get the results I desire, such as setting it to read from the "Microsoft Project and Visio Installs Inventory Notices" subfolder.

$GetMailItems = @(
    $OutlookInbox = 6
    $Outlook = New-Object -Com Outlook.Application;
    $NameSpace = $Outlook.GetNameSpace("MAPI");
    $Inbox = $NameSpace.GetDefaultFolder($OutlookInbox)

    $Inbox.Items | ForEach {
        If ($_.Body -match "Project|Visio" -and $_.Body -notmatch "MUI|Service Pack|Update|Viewer|Vision") 
        {
            Write-Output $_.Body
        }})

$GetMailItems

Thanks

April 21, 2015 at 11:23 am

You can specify the subfolder to read from before the ForEach statement:

($Inbox.Folders | ?{$_.Name -eq 'Subfolder'}).Items

Hope this helps.