-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionFirst-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
Not a bug, but a request for "Send-MailMessage" cmdlet
$From = $email
$To = $Number
$Body = "Something"
$Subject = $null
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
-Credential $CredRESULT:
Send-MailMessage : Cannot validate argument on parameter 'Subject'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:8 char:52
+ -Body $Body -SmtpServer $SMTPServer -Subject $Subject -port $SM ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage
CAUSE:
[Parameter(Mandatory=$true, Position=1)]
[Alias('sub')]
[ValidateNotNullOrEmpty()]
[string]
${Subject},
Emails do not require subjects to be present. However, in the Send-MailMessage cmdlet, the $subject parameter is set to "Mandatory=$true". Since an email does not require a subject, this should really be set to "$false".
I've created my own workaround this, but I feel that this should be changed since a subject is not imperative for an email to be sent.
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionFirst-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module