Using Powershell to read outlook 2010 emails in Windows 7
-
Wednesday, January 23, 2013 10:57 PM
I have been using the same script for accessing the emails in Windows XP environment which still works fine.
However, I am trying to do the same in Windows 7, outlook 2010 and have been getting errors. Please help.
[Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.OutlookViewCtl") | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$outlook = New-Object -comobject outlook.application
$mapi = $outlook.GetNamespace("MAPI")I get the following error:
New-Object : Cannot load COM type outlook.application.
At line:8 char:16
+ $outlook = New-Object <<<< -comobject outlook.application
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommandYou cannot call a method on a null-valued expression.
At line:9 char:21
+ $mapi = $outlook.GetNamespace <<<< ("MAPI")
+ CategoryInfo : InvalidOperation: (GetNamespace:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullThank you in advance!
AJ
All Replies
-
Wednesday, January 23, 2013 10:58 PM
I have been using the same script for accessing the emails in Windows XP environment which still works fine.
However, I am trying to do the same in Windows 7, outlook 2010 and have been getting errors. Please help.
[Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.OutlookViewCtl") | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$outlook = New-Object -comobject outlook.application
$mapi = $outlook.GetNamespace("MAPI")I get the following error:
New-Object : Cannot load COM type outlook.application.
At line:8 char:16
+ $outlook = New-Object <<<< -comobject outlook.application
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommandYou cannot call a method on a null-valued expression.
At line:9 char:21
+ $mapi = $outlook.GetNamespace <<<< ("MAPI")
+ CategoryInfo : InvalidOperation: (GetNamespace:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullThank you in advance!
AJ
- Merged by Bill_StewartMicrosoft Community Contributor, Moderator Wednesday, January 23, 2013 11:03 PM Duplicate thread
-
Wednesday, January 23, 2013 11:05 PMModerator
Hi,
I'm going to attempt psychic debugging and guess that your Windows 7 machine is x64 and you're running the script from a 64-bit PowerShell window. If that's the case, try running your script from a 32-bit PowerShell window.
Bill
- Proposed As Answer by jrvMicrosoft Community Contributor Wednesday, January 23, 2013 11:20 PM
- Marked As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Wednesday, February 06, 2013 10:41 PM

