Como ler system.net/mailSettings/smtp de Web.config

Este é meuweb.config configurações de email:

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="[email protected]">
        <network defaultCredentials="true" host="localhost" port="587" userName="[email protected]" password="123456"/>
      </smtp>
    </mailSettings>
  </system.net>

e aqui está como eu tento ler os valores deweb.config

 var smtp = new System.Net.Mail.SmtpClient();
 var credential = new System.Net.Configuration.SmtpSection().Network;

 string strHost = smtp.Host;
 int port = smtp.Port;
 string strUserName = credential.UserName;
 string strFromPass = credential.Password;

Mas as credenciais são sempre nulas. Como posso acessar esses valores?

questionAnswers(6)

yourAnswerToTheQuestion