PS C:\> C:\EmailTest.ps1
Send-MailMessage : Cannot validate argument on parameter 'To'. The argument is null or empty. Provide an argument that is not null
or empty, and then try the command again.
At C:\EmailTest.ps1:26 char:22
+ Send-MailMessage -To "$MailtTo" -from "$MailFrom" -Subject $MailSubject -SmtpSer ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage
There is a typo in your script. You've declared variable as $MailTo (with one t), but, then, you try to access it as $MailtTo (with double T), thus, the issue. Thanks.