views:

422

answers:

1

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

This works if I hard code a single email address however I now want to email multiple developers and the script is failing. 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 change the To line to read $(Recipients) the first person on the list will get the email, subsequent addresses do not recieve the email.

I then changed the To line to what you see below @(Recipients), as I thougt it might then loop round each recipient. No such luck!!! I get the error message

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

The file that I read in is simply a text file in the format (emailAddress1),(emailAddress2), etc

+2  A: 

The task ReadLinesFromFile reads a list of items from a text file. But the file must have one item on each line.

With your text file in the format (emailAdress1),emailAddress2)... you will only have one item containing (emailAdress1),emailAddress2).... Your email.txt should be like this:

emailAdress1
emailAdress2
...

You get items from ReadLinesFromFile task and not properties, so modify your task like that:

<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>

(There is a bug in the log of the mail target, even with multiple recipients only the first one will be shown in the log.)

madgnome