How to email multiple addresses using MSbuild

I have a goal in my build script that will send an email with an attachment detailing the svn changes for the module.

This works if I hard-code a single email address, but now I want to send several emails to several developers, and the script does not work. Below is the code

 <Target Name="MailInformationUpdate" DependsOnTargets="ZipArtifact" Condition="!Exists('BUILD_IS_PERSONAL')">

    <ReadLinesFromFile File="$(BuildDir)\$(recipientListFileName)">
      <Output PropertyName="Recipients"  TaskParameter="Lines"/>
    </ReadLinesFromFile>
    <Mail SmtpServer="$(smptServer)"
           To="@(Recipients)"
           From="$(senderEmail)"
           Body="Attached is a list of the changes made since the last release. "
       Subject="This module has been updated. You may wish to update." Attachments="$(BuildDir)\Builds\$(svnChangeFileName)"   
          />    
  </Target>

If I changed the To line to read $ (Recipients), the first person on the list will receive an email, subsequent addresses will not receive an email.

Then I changed the To line to what you see below @ (Recipients), since I could then go around each recipient. There is no such luck !!! I get an error

Emailing "{0}".
    <path> error : A recipient must be specified.

, , - ( 1), ( 2) ..

+3
1

ReadLinesFromFile . .

(emailAdress1), emailAddress2)... , (emailAdress1), emailAddress2).... email.txt :

emailAdress1
emailAdress2
...

ReadLinesFromFile, , :

<Target Name="MailInformationUpdate" DependsOnTargets="ZipArtifact" Condition="!Exists('BUILD_IS_PERSONAL')">

  <ReadLinesFromFile File="$(BuildDir)\$(recipientListFileName)">
    <Output ItemName="Recipients"  TaskParameter="Lines"/>
  </ReadLinesFromFile>
  <Mail SmtpServer="$(smptServer)"
       To="@(Recipients)"
       From="$(senderEmail)"
       Body="Attached is a list of the changes made since the last release. "
       Subject="This module has been updated. You may wish to update."
       Attachments="$(BuildDir)\Builds\$(svnChangeFileName)"   
      />    
</Target>

( , .)

+6

Source: https://habr.com/ru/post/1702408/


All Articles