Can I use NAnt to query my database and use the results as parameter values?
I spent 15 minutes searching the Task lists of NAnt and NAntContrib, and searching Google, but came up empty-handed.
I want to send an email to every user of my system when I promote my code. I have a list of 开发者_C百科email addresses in my database, and I have a functioning email task. So, how can I connect the two?
Thanks! D
When I get time to return to this, I think I will issue a select statement via sqlcmd.exe, saving the results (a list of email addresses) to a text-file. I will then read the contents of the text file, and use the values therein to address my emails. Seems like a hack -- please tell me there's something more elegant....?
<target name="uat.notify">
<exec program="${sqlcmd.exe}" commandline='-S DB_SERVER -b -o email.txt -Q "set nocount on;use DATABASE;select email_address from dbo.t_users" -h -1' />
<foreach item="Line" in="email.txt" property="email.address">
<if test="${string::get-length(string::trim(email.address)) > 0}" >
<mail failonerror="false"
from="SENDER@DOMAIN.com"
tolist="${string::trim(email.address)}"
format="Html"
subject="test:notify"
mailhost="MAILHOST"
>
<files>
<include name="notify.htm" />
</files>
</mail>
</if>
</foreach>
</target>
精彩评论