QuickBlog: PowerShell – Extracting email from Outlook but using .NET code…

In my previous QuickBlog I show a sample code of extracting email from Outlook but I was using COM object “Outlook.Application”.  Well, here’s the same code but using .NET “Microsoft.Office.Interop.Outlook” assembly.  The code look the same:

$o = New-Object Microsoft.Office.Interop.Outlook.ApplicationClass
$getmail = $o.GetNamespace(‘MAPI’)
$olxFolder = $getmail.GetDefaultFolder(‘olFolderInbox’);
$olxFolder.items | ? {$_.to -eq "ITDBA_Grp"} | select -first 25 SentOn, SenderName, Subject | fl

Still is a 5 liner to start getting something out of your Outlook Inbox.

Simple and powerful!


About maxt2posh

I’m from Puerto Rico, have been working with computers since 1979. Throughout many years, I have worked with SQL Server Technologies, provided support to Windows Servers/Client machines, Microsoft Virtualization Technologies, and build some Visual Studio solutions. I’m a Microsoft PowerShell MVP since 2009 and MVP SAPIEN Technologies since 2010. I speak in most of the SQLSaturday, IT Pro and .NET camps events around the Florida’s State. Also founder of the Florida PowerShell User Group which meeting every 3rd Tuesday evening of the month.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s