Skip to content

Send-MailMessage incorrectly handling ValueFromPipelineByPropertyName parameters #7591

@dantraMSFT

Description

@dantraMSFT

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.

Steps to reproduce

$object = [PSCustomObject]@{To = $address; From = $address;  Subject = $subject;  Body = $body; SmtpServer = '127.0.0.1'}
$object | Send-MailMessage

Expected behavior

The mail is sent.

Actual behavior

System.ArgumentNullException: Value cannot be null
Parameter name: address

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions