none
Outlook Application RRS feed

  • Question

  • Hello

    I would like to use the following PowerShell script, however, while executing $outlook = new-object -comobject outlook.application nothing is return to the $Outlook variable.. I am using OUTLOOK 2010 release.

    I found the COM outlook.application after executing Get-WmiObject Win32_COMClass “and “Get-ChildItem HKLM:\Software\Classes

    I am missing something.

    Thank you in advance.

    [Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.Outlook") | out-null

    $olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]

    $outlook = new-object -comobject outlook.application

    $namespace = $outlook.GetNameSpace("MAPI")

    $folder = $namespace.getDefaultFolder($olFolders::olFolderJunk)

    $folder.items.count


    Learning PowerShell scripting


    Monday, March 10, 2014 2:56 PM

Answers

  • I rebooted my PC, started PowerShell as administrator, run the script and resolved the issue.

    Thank you for your time.

    This is the error I got after executing the PS command in basic mode:

    new-object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046}
    failed due to the following error: 800702e4 The requested operation requires elevation. (Exception from HRESULT: 0x800702E4).


    Learning PowerShell scripting

    Monday, March 10, 2014 5:39 PM

All replies

  • How do you know nothing is returned?

    PS C:\scripts>  $outlook=new-object -comobject outlook.application
    PS C:\scripts> $outlook.GetType()
    
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     False    __ComObject                              System.MarshalByRefObject
    
    
    PS C:\scripts>
    


    ¯\_(ツ)_/¯

    Monday, March 10, 2014 3:57 PM
  • Thank you.

    The variable does not contain any data from the New-Object command.

    I execute your command does not display anything.

    Because the command is not execute successfully, the $outlook variable is not created in PS environment.


    Learning PowerShell scripting

    Monday, March 10, 2014 5:04 PM
  • Thank you.

    The variable does not contain any data from the New-Object command.

    I execute your command does not display anything.

    Because the command is not execute successfully, the $outlook variable is not created in PS environment.


    Learning PowerShell scripting

    Then you need to reinstall Outllok

    Run a repair on Outlook.

    If you are in a Corporate setting your admins may have disabled Outlook object access.


    ¯\_(ツ)_/¯

    Monday, March 10, 2014 5:10 PM
  • I rebooted my PC, started PowerShell as administrator, run the script and resolved the issue.

    Thank you for your time.

    This is the error I got after executing the PS command in basic mode:

    new-object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046}
    failed due to the following error: 800702e4 The requested operation requires elevation. (Exception from HRESULT: 0x800702E4).


    Learning PowerShell scripting

    Monday, March 10, 2014 5:39 PM