Search code examples
asp.netweb-configweb-config-transform

Web.config - T4 Transformation - SMTP section


Hey Guys I'm trying to do a transformation of the SMTP section of a web config file.

This is what I have got so far:

<mailSettings>
  <smtp>
    <network host="smtp.sendgrid.net" port="25" userName="UserName1Here" password="Password1Here" defaultCredentials="false" />
  </smtp>
</mailSettings>

Then inside the .production version of the Webconfig I have this:

<mailSettings>
<smtp xdt:Transform="Replace">
  <network host="smtp.sendgrid.net" port="25" userName="UserName2Here" password="Password2Here" defaultCredentials="false" />
</smtp>

Can't seem to get it working... what am I missing any ideas?


Solution

  • Fixed it...

    What I was missing was the route element of the web-config file. Which was

    <system.net>
    

    So now this works

     <system.net>
    <mailSettings>
      <smtp xdt:Transform="Replace">
        <network host="smtp.sendgrid.net" port="25" userName="UserName2Here" password="password2here" defaultCredentials="false" />
      </smtp>
    </mailSettings>
    

    Hope this helps someone else.