In your PowerShell code, you're accessing IMAPConfig()
as a static method of the IMAPConfig
class, which I'm guessing is not valid. In order to use an object constructor in PowerShell, you need to use the New-Object
cmdlet.
The -TypeName
parameter specifies the .NET class that you want to instantiate. The -ArgumentList
parameter accepts an array of arbitrary System.Object
objects that represent the constructor parameters.
$config = New-Object -TypeName InterIMAP.IMAP.IMAPConfig -ArgumentList @('imap.gmail.com', $User, $Password, $true, $true, 'INBOX');