How to set -password property for Send-MailMessage cmdlet?

I’m referencing this URL:

to send an automated email. I would like to use a different username and password to connect to the smtp server. I found this URL to encrypt my password.

1.) How can I incorporate the encrypted password into the Send-MailMessage command?

2.) Is there a better or more secure way of doing this?

thanks in advance!


Install-Module AZSBTools
$Cred = Get-SBCredential -UserName 'my smtp user name'

# to see built-in help
help Get-SBCredential -Show

Works great! Thanks Sam.

BTW - The spelling for the module above should be AZSBTools for anyone else looking to install this module.