• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Can Powershell parse email?

K

Keith Hill [MVP]

#2
"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 Computer

M

Marco Shaw [MVP]

#3
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 Computer

S

Shay Levi

#4
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 Computer

K

kelly goff

#5
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 Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)