Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Modify Powershell script to pause after reading each email

I would like to modify this part of a Powershell script so that when it looks through any new emails, that it separates each email with
a line so that it is distinguishable..
or that it pauses and asks the user if they want to continue checking..   (to pause after each email)

# Do/while loop for paging through the folder
    # Set what we want to retrieve from the folder. This will grab the first $pagesize emails
    $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView($numOfEmailsToRead,$index)
    # Retrieve the data from the folder
    $findResults = $service.FindItems([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$view)
    foreach ($item in $findResults.Items)
        # load the additional properties for the item

        # Output the results
        "From: $($item.From.Name)"
        "Subject: $($item.Subject)"
    # Increment $index to next block of emails
    $index += $numOfEmailsToRead
} while ($findResults.MoreAvailable) # Do/While there are more emails to retrieve
Avatar of oBdA

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E=mc2


Excellent, thank you.