• Loading...
ComponentPro UltimateMail

Using UltimateMail in PowerShell

Language Filter: AllSend comments on this topic to ComponentPro

With only few steps, you can easily and quickly use UltimateMail component in PowerShell as described below:

Loading assembly

To load UltimateMail component for using in PowerShell, simply use the [Reflection.Assembly]::LoadFrom command as demonstrated below:

PowerShell - Loading Assembly
PS C:\> [Reflection.Assembly]::LoadFrom("C:\ComponentPro\UltimateMail vX.X.X.X\Bin\NetX_X\ComponentPro.Mail.dll")

Loading the assembly from GAC

PowerShell - Loading Assembly from GAC
PS C:\> [Reflection.Assembly]::LoadFrom("ComponentPro.Mail, Version=X.X.X.X, Culture=neutral, PublicKeyToken=0efede2d78b28dff")

Using Imap class (similarly with other classes)

Now you are ready to use all classes inside the UltimateMail component. For example, to Connect, Authenticate and Download a message from an IMAP server, you can use the following script:

PowerShell - Using UltimateMail
PS C:\> $client = New-Object ComponentPro.Net.Mail.Imap

PS C:\> $client.Connect("myserver")

PS C:\> $client.Authenticate("user", "pass")

PS C:\> $client.Select("INBOX")

PS C:\> $client.DownloadMessage(1)

PS C:\> $client.Disconnect()

PS C:\> $client.Dispose()