I am trying to access Microsoft outlook from Powershell but I am not able to get access to it. I don’t know what is the problem. It is a company firewall or I am not writing a correct powershell command for access Outlook. Any help appreciated???
Set-ExecutionPolicy RemoteSigned
# use MAPI name space
$outlook = new-object -com outlook.application;
$mapi = $outlook.GetNameSpace("MAPI");
# link to the folder
$olFolderPath = "\\shantanu.gupta@EarthSQL.com\Inbox"
I am getting this error
new-object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server
execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
At C:\Users\ShantanuGupta\Desktop\EmailTesting.ps1:4 char:12
- $outlook = new-object -com outlook.application;
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ResourceUnavailable: (
[New-Object], COMException
- FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
- CategoryInfo : ResourceUnavailable: (
You cannot call a method on a null-valued expression.
At C:\Users\ShantanuGupta\Desktop\EmailTesting.ps1:5 char:1
- $mapi = $outlook.GetNameSpace(“MAPI”);
-
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull