I need a powershell script that will download mail sent to a mailbox from a specific email address to a folder path such as \\server01\temp

I need a power shell script to checks a specific email address or mailbox on our Exchange server, lets say xyz@domain.com and every time I receives and email from another specific address, lets say abc@comp;any.com it downloads the email and attachment to a folder such as \\server01\temp......Is there a quick way to write a powershell script for this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sebastian StrittmatterSoftware DevelopmentCommented:
What access methods do you have to access your mailbox?
 * Outlook
 * something else.
Thor2923Author Commented:
we are using exchange 2013 i know we use IMAP and OUTLOOK....I maybe I should have made this more of an exchange question than PowerShell
Michael B. SmithManaging ConsultantCommented:
Why not simply use Search-Mailbox?
Sebastian StrittmatterSoftware DevelopmentCommented:
I wrote a little script for this.
For this script you need outlook with the specfic mail account. You can run this script as task in a time period.

The script marks the worked messages as read.

I hope this helps.

    [string]$nameOfOutlookAccount, # Name of outlook-Accoun have to be visible in outlook
    [string]$nameOfInboxFolder,    # name of the inbox folder visible in outlook
    [string]$emailOfSender,        # name of the sender mail
    [string]$attachTargetPath      # path for the attachments

$out = New-Object -ComObject Outlook.Application

$mapi = $out.GetNamespace("MAPI")

$account = $mapi.Folders.Item($nameOfOutlookAccount);

$inbox = $account.Folders.Item($nameOfInboxFolder);

# Loop through inbox
$inbox.Items | % {
    if($_.UnRead -eq $true -and $_.SenderEmailAddress -eq $emailOfSender) {
        # Save the attachment to directory an mark message as read
        $_.Attachments | % {
            $p = $(Resolve-Path "$attachTargetPath\").Path
            Write-Host "Saved Attachment $($p)$($_.FileName)"

        $_.UnRead = $false
        Write-Host "Marked message as read" -ForegroundColor Green

# Close Outlook     

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thor2923Author Commented:
this was fantastic thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.