How to mail to bcc using powershell
To send an email to a blind carbon copy (BCC) recipient using PowerShell, you can use the Send-MailMessage
cmdlet. Here's an example:
Send-MailMessage -From "your-email-address" -To "recipient-email-address" -Subject "Subject of the email" -Body "Body of the email" -Bcc "bcc-recipient-email-address"
Replace the placeholders with your actual email address, recipient email address, subject, body, and BCC recipient email address.
Here's a breakdown of the parameters:
-From
: The sender's email address.-To
: The recipient's email address.-Subject
: The subject of the email.-Body
: The body of the email.-Bcc
: The email address of the BCC recipient.
You can also specify additional parameters, such as:
-SmtpServer
: The SMTP server to use for sending the email.-UseSsl
: A switch to enable SSL/TLS encryption for the email transmission.-Credential
: A credential object to use for authentication with the SMTP server.
Here's an example with additional parameters:
$cred = Get-Credential -Username "your-email-address" -Password "your-password"
Send-MailMessage -From "your-email-address" -To "recipient-email-address" -Subject "Subject of the email" -Body "Body of the email" -Bcc "bcc-recipient-email-address" -SmtpServer "smtp.example.com" -UseSsl -Credential $cred
Make sure to replace the placeholders with your actual values and adjust the parameters as needed.
Note: The Send-MailMessage
cmdlet is available in PowerShell 3 and later versions. If you're using an earlier version, you can use the Send-Mail
cmdlet instead, but it doesn't support BCC recipients.