Hi support.
I want to have a Powershell script access an IMAP mail server and do some automation.
Since I have an Aspose.Regarding the email license, I thought I would try using Aspose.Email Aspose.Email (23.11.0.0, .NETFrameworE v4.5).
The Powershell (7.3) code below throws the following error:
Error: Exception calling “ListMessages” with “1” argument(s): “The type initializer for ‘#=zCFP7hrvmVjPEO6to_WD035ORPOGDBp7EzQ==’ threw an exception.”
Research points to requiring loading (some or all) dll’s referenced by Aspose.Email (which is quite a few).
Can you help?
/Morten
$emailLicense = New-Object Aspose.Email.License
$emailLicense.SetLicense($path_License)
$imapClient = New-Object Aspose.Email.Clients.Imap.ImapClient($server_host, $account_username, $account_passowrd)
$imapClient.SecurityOptions = [Aspose.Email.Clients.SecurityOptions]::Auto
$imapQueryBuilder = New-Object Aspose.Email.Clients.Imap.ImapQueryBuilder
$imapQueryBuilder.HasNoFlags([Aspose.Email.Clients.Imap.ImapMessageFlags]::IsRead)
$query = $imapQueryBuilder.GetQuery()
$imapClient.SelectFolder(“Inbox”)
try {
$messageInfoCol = $imapClient.ListMessages($query)
"Initial Unread Count: " + $messageInfoCol.Count
} catch {
Write-Output “Error: $_”
}