Email send issue

  • I getting an error try to use this piece of code.

    Error:

    Send-MailMessage : An invalid character was found in the mail header: ','.

    Thanks.

    $messageParameters = @{
    From = "xxxx@xxx.com"
    To = "xxx@xxx.com,yyy@yyy.com,zzz@zzz.com"
    Subject = "DBLocks "
    Body = "Job Status"
    SMTPServer = "xxxxxx"
    Attachments = $file.FullName}

    Send-MailMessage @messageParameters
  • The to list needs to be an array @() not a comma separated string 🙂

  • I tried something like this then used $ToString

     

        $ArrayOfStrings = @("xxxx@.xxxxcom","yyyyy@yyyy.com","zzzz@zzzz.com")
    $ToString = $ArrayOfStrings -join ","
  • Don't convert it to a string at all, the to parameter should just be the array if it's going to multiple addresses.

  • can't get it to work. Would you mind supplying me the syntax.

    Many Thx.

  • This works fine for me,

     

    $messageParameters = @{
    From = "xxxx@xxx.com"
    To = @("asfadsf@dsdasf.com", "djshgfkdhas@hcbvmxc.com")
    Subject = "DBLocks "
    Body = "Job Status"
    SMTPServer = "SMTPSERVER"
    }

    Send-MailMessage @messageParameters
  • I thought that is what I had, but must have a typo or something.

     

    Thanks Again that worked!!!.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply