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
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
$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
Which do you need?
Kelly Goff
tried to use the com commands but it is only being used in outlook client side :(
Thanks
> On Wednesday, March 26, 2008 11:37 AM akcor wrote:
> Is there a way for powershell to read an inbox and look for a specific string
> in the subject or body?
>> On Wednesday, March 26, 2008 11:52 AM Keith Hill [MVP] wrote:
>> "akcorr" <akc...@discussions.microsoft.com> wrote in message
>> news:CE0C6455-6881-4302...@microsoft.com...
>>
>> 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
>>> On Wednesday, March 26, 2008 12:06 PM Marco Shaw [MVP] wrote:
>>> akcorr wrote:
>>>
>>> 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
>>>> On Wednesday, March 26, 2008 2:43 PM kelly goff wrote:
>>>> akcorr wrote:
>>>> 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
>>>>> On Friday, March 28, 2008 6:15 AM Shay Levi wrote:
>>>>> 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
>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>> Book Review: Google Analytics
>>>>> http://www.eggheadcafe.com/tutorials/aspnet/a855a620-50a8-487c-9fac-b85f8fda2442/book-review-google-analytics.aspx