Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Accessing non-default calendar in Outlook 2010 from PowerShell code

$
0
0

Hi,

I'm trying to write a PowerShell script that will detect and remove duplicates in anon-default Outlook 2010 calendar.

I understand I need to navigate the available calendars to find the one I want, as described in http://msdn.microsoft.com/en-us/library/office/ff867692(v=office.14).aspx

I'm trying to get a CalendarModule instance (getting inspiration from http://www.outlookcode.com/threads_print.aspx?forumid=2&messageid=27771) as follows:

 

Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -comobject Outlook.Application
# Ensure we are logged into a session
$session = $outlook.Session
$session.Logon()

[Microsoft.Office.Interop.Outlook.CalendarModule] $module = $outlook.Application.ActiveExplorer().NavigationPane.Modules.GetNavigationModule([Microsoft.Office.Interop.Outlook.OlNavigationModuleType]::olModuleCalendar)

 

but all I get is:

 Cannot convert the "Microsoft.Office.Interop.Outlook.NavigationModuleClass" value of type
"Microsoft.Office.Interop.Outlook.NavigationModuleClass" to type "Microsoft.Office.Interop.Outlook.CalendarModule".

 It seems GetNavigationModule() returns an instance of NavigationModuleClass, not of NavigationModule.

What's wrong in my reasoning / code?

P.S. if this is the wrong place to ask, and there's a better place to ask questions about Outlook automation (from PowerShell or using the PIA) just do redirect me there.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>