Send-MailMessage with predefined parameters

suggest change
$parameters = @{
 From = 'from@bar.com'
 To = 'to@bar.com'
 Subject = 'Email Subject'
 Attachments =  @('C:\files\samplefile1.txt','C:\files\samplefile2.txt')
 BCC = 'bcc@bar.com'
 Body = 'Email body'
 BodyAsHtml = $false
 CC = 'cc@bar.com'
 Credential = Get-Credential
 DeliveryNotificationOption = 'OnSuccess'
 Encoding = 'UTF8'
 Port = '25'
 Priority = 'High'
 SmtpServer = 'smtp.com'
 UseSsl = $true
}

# Get-Credential runs while the hashtable is created, so the prompt happens before Send-MailMessage.
# Splatting uses @ instead of $ in front of the variable name.
Send-MailMessage @parameters

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents