Windows Vista Forums

Can Powershell parse email?

  1. #1


    akcorr Guest

    Can Powershell parse email?

    Is there a way for powershell to read an inbox and look for a specific string
    in the subject or body?

      My System SpecsSystem Spec

  2. #2


    Keith Hill [MVP] Guest

    Re: Can Powershell parse email?

    "akcorr" <akcorr@xxxxxx> wrote in message
    news:CE0C6455-6881-4302-9C01-54C5F319D7CC@xxxxxx

    > Is there a way for powershell to read an inbox and look for a specific
    > string
    > in the subject or body?
    If you are using Outlook then you can use Outlook COM Automation. Have a
    look at this KB article:

    http://support.microsoft.com/default.aspx/kb/310244

    That C# code should translate to PowerShell script pretty easily.

    --
    Keith


      My System SpecsSystem Spec

  3. #3


    Marco Shaw [MVP] Guest

    Re: Can Powershell parse email?

    akcorr wrote:

    > Is there a way for powershell to read an inbox and look for a specific string
    > in the subject or body?
    Now, if you're dealing with an IMAP mailbox, you can also check out
    NetCmdlets:
    http://www.nsoftware.com/powershell

    They have a get-imap cmdlet that can retrieve messages, and then you can
    search through them after...

    There's also a get-pop (or get-pop3 cmdlet). Don't try to use
    PowerShell to read the Inbox from Outlook Express or Live Mail directly
    from the local inbox file! It can't decode it, as far as I know.

    Marco

    --
    Microsoft MVP - Windows PowerShell
    http://www.microsoft.com/mvp

    PowerGadgets MVP
    http://www.powergadgets.com/mvp

    Blog:
    http://marcoshaw.blogspot.com

      My System SpecsSystem Spec

  4. #4


    Shay Levi Guest

    Re: Can Powershell parse email?


    If your email client is outlook:


    $olFolderInbox = 6
    $outlook = new-object -com outlook.application;
    $ns = $outlook.GetNameSpace("MAPI");
    $inbox = $ns.GetDefaultFolder($olFolderInbox)


    $inbox.items | foreach {
    if($_.subject -match "something") {...}
    if($_.body -match "something") {...}
    }



    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com

    > Is there a way for powershell to read an inbox and look for a specific
    > string in the subject or body?
    >


      My System SpecsSystem Spec

  5. #5


    kelly goff Guest

    Re: Can Powershell parse email?

    akcorr wrote:

    > Is there a way for powershell to read an inbox and look for a specific string
    > in the subject or body?
    Yes, it can. But how you do it depends on whether you are running the
    script on the server or a client.

    Which do you need?

    Kelly Goff

      My System SpecsSystem Spec


Can Powershell parse email?
Similar Threads
Thread Forum
XML parse issue .NET General
Here is a PowerShell script to parse nmap XML output files. PowerShell
MSXML 4.0 SP2 Parse and SDK Vista performance & maintenance
How Powershell parse HTMLDocument? PowerShell
Parse XML files from Powershell? PowerShell