'Powersell Press "yes" outlook dialog box

I want to do a powershell script to automatically open an .ics file from a folder. The problem is that, after running it, a dialog box appears in an outlook desktop window:

enter image description here

I would like to automatically press "I" to import that file without clicking. Can it be done as a background process in w10? The scrit will be run every hour

Thanks folks!

EDIT: I post the "code", I didn't do that before cause it cannot be simpler ahha

Invoke-Item "A:\path"

I also tried to do that via VBA but outlook does not permit automatically accept meeting for security reasons.



Solution 1:[1]

Use the NameSpace.OpenSharedItem method which opens a shared item from a specified path or URL. This method is used to open iCalendar appointment (.ics) files, vCard (.vcf) files, and Outlook message (.msg) files. The type of object returned by this method depends on the type of shared item opened.

The OpenSharedItem method does not support iCalendar calendar (.ics) files. To open iCalendar calendar files, you can try to use the OpenSharedFolder method of the NameSpace object. For example:

Public Sub OpenSharedHolidayCalendar() 
 Dim oNamespace As NameSpace 
 Dim oFolder As Folder 
 On Error GoTo ErrRoutine 
 
 Set oNamespace = Application.GetNamespace("MAPI") 
 Set oFolder = oNamespace.OpenSharedFolder("webcal://icalx.com/public/icalshare/US32Holidays.ics")  
 oFolder.Display 
EndRoutine: 
 On Error GoTo 0 
 Set oFolder = Nothing  
 Set oNamespace = Nothing  
Exit Sub  
ErrRoutine:  
 MsgBox Err.Description, vbOKOnly, Err.Number & " - " & Err.Source  
 GoTo EndRoutine  
End Sub

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugene Astafiev