Windows Vista Forums

Send-MailMessage to Multiple Recipients from Script
  1. #1


    ABK Guest

    Send-MailMessage to Multiple Recipients from Script

    Hello Everyone,
    Have this line in my PS script:
    Send-MailMessage -Body $Body -Cc cc@xxxxxx -SmtpServer test.com -From
    from@xxxxxx -To $MultipleRecipients -Subject $Subject
    $MultipleRecipients variable contains several e-mail addresses separated by
    comma.
    When I run my script only the 1st e-mail recipient from $MultipleRecipients
    variable gets the mssage, the other ones are ignored.
    If I execute this from PS command line (replacing variables with values),
    everything works as expected.



    Your help is greatly appreciated.
    ABK

      My System SpecsSystem Spec

  2. #2


    Vadims Podans [MVP] Guest

    Re: Send-MailMessage to Multiple Recipients from Script

    Looks like your $MultipleRecipients is simple string. You should pass
    recipients as [string[]] (string array).
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "ABK" <ABK@xxxxxx> rakstīja ziņojumā
    "news:53DBE428-E78C-4DC3-9488-8BAC5C8075C6@xxxxxx"...

    > Hello Everyone,
    > Have this line in my PS script:
    > Send-MailMessage -Body $Body -Cc cc@xxxxxx -SmtpServer test.com -From
    > from@xxxxxx -To $MultipleRecipients -Subject $Subject
    > $MultipleRecipients variable contains several e-mail addresses separated
    > by
    > comma.
    > When I run my script only the 1st e-mail recipient from
    > $MultipleRecipients
    > variable gets the mssage, the other ones are ignored.
    > If I execute this from PS command line (replacing variables with values),
    > everything works as expected.
    >
    > Your help is greatly appreciated.
    > ABK

      My System SpecsSystem Spec

  3. #3


    ABK Guest

    Re: Send-MailMessage to Multiple Recipients from Script

    Vadim,

    It works now. Thank you so much.

    Aleksandr

    "Vadims Podans [MVP]" wrote:

    > Looks like your $MultipleRecipients is simple string. You should pass
    > recipients as [string[]] (string array).
    > --
    > WBR, Vadims Podans
    > MVP: PowerShell
    > PowerShell blog - www.sysadmins.lv
    >
    > "ABK" <ABK@xxxxxx> rakstīja ziņojumā
    > "news:53DBE428-E78C-4DC3-9488-8BAC5C8075C6@xxxxxx"...

    > > Hello Everyone,
    > > Have this line in my PS script:
    > > Send-MailMessage -Body $Body -Cc cc@xxxxxx -SmtpServer test.com -From
    > > from@xxxxxx -To $MultipleRecipients -Subject $Subject
    > > $MultipleRecipients variable contains several e-mail addresses separated
    > > by
    > > comma.
    > > When I run my script only the 1st e-mail recipient from
    > > $MultipleRecipients
    > > variable gets the mssage, the other ones are ignored.
    > > If I execute this from PS command line (replacing variables with values),
    > > everything works as expected.
    > >
    > > Your help is greatly appreciated.
    > > ABK
    >
    >

      My System SpecsSystem Spec

Send-MailMessage to Multiple Recipients from Script problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple recipients Fontman Vista mail 1 15 Jan 2010
send email with multiple recipients pug Live Mail 2 13 May 2009
MULTIPLE RECIPIENTS USING Bcc otismack Vista mail 7 28 Sep 2008
Unable to send to multiple recipients akn Vista mail 2 21 Apr 2008
How to send mail to multiple recipients jek Vista mail 2 07 Sep 2007