You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation is processing parameters in BeginProcessing. While this works for parameters that are explicitly passed to the cmdlet, it fails for parameters that are populated form properties of the pipeline object because parameters are not set until the pipeline object is sent to ProcessRecord.
The logic for parameters bound from the pipleline needs to be moved to ProcessRecord.
Send-MailMessage in its current implemented code logic only supports piping attachment file paths into the cmdlet:
file1.txt, file2.txt |Send-MailMessage-To $address-From $address-SmtpServer 127.0.0.1-Subject "Mail with attachments"
In this case, the file paths file1.txt and file2.txt are added to the mail message in the ProcessRecord block of the cmdlet and the mail is sent in the EndProcessing block.
Using named parameter pipeline binding, the mail has to be sent within the ProcessRecord block, because the pipeline may contain several input objects with named parameters:
Small problem:
Since Attachments is the default pipeline input and it's type is string[] the named parameter objects would be bound as well to Attachments.
For the case above, the Attachments property would still be set like this:
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Activity
ThreeFive-O commentedon Sep 15, 2018
Send-MailMessagein its current implemented code logic only supports piping attachment file paths into the cmdlet:In this case, the file paths
file1.txtandfile2.txtare added to the mail message in theProcessRecordblock of the cmdlet and the mail is sent in theEndProcessingblock.Using named parameter pipeline binding, the mail has to be sent within the
ProcessRecordblock, because the pipeline may contain several input objects with named parameters:Small problem:
Since
Attachmentsis the default pipeline input and it's type isstring[]the named parameter objects would be bound as well to Attachments.For the case above, the Attachments property would still be set like this:
Since those are not valid file paths, the mail message would throw.
Therefore the two cases have to be differentiated:
EndProcessingblock (current behavior)ProcessRecordblock (described above)microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.