Skip to content

Send-MailMessage: Positional Parameter Error #1751

Closed
@hojomic

Description

@hojomic

Issue Type: Bug

Run the following script with appropriate values for sender, recipient and SMTP relay:

 $from		= "\<Sender\>"
 $recipient	= "\<Recipient\>"
 $smtpRelay	= "\<SMTP Relay\>"
 $subject		= "E-mail Encryption (SMTP): Test 1"
 $body		= "Testing FuseMail SMTP..."
 Send-MailMessage –From $from –To $recipient –Subject $subject –Body $body -SmtpServer $smtpRelay -Port 25

This generates the following error:

Send-MailMessage : A positional parameter cannot be found that accepts argument 'Testing FuseMail SMTP...'.
At C:\Users\<User>\<OneDrive>\Development\PowerShell\Scripts\Send-EmailUsingSmtpRelay.ps1:6 char:1
+ Send-MailMessage –From $from –To $recipient1 –Subject $subject  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage

Running the same script in the PowerShell console or PowerShell ISE works without issue.

Also note the unexpected characters '–' in the error message.

Extension version: 1.11.0
VS Code version: Code 1.31.0 (7c66f58312b48ed8ca4e387ebd9ffe9605332caa, 2019-02-05T22:35:56.624Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.86GB (7.43GB free)
Process Argv
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions