Credential Caching issue
<p>I have a static helper method that I wrap around SMTPClient to send email.</p>

<p>I am storing the SMTP authentication in the web.config -> in the default location that System.Net namespace objects look for.</p>

<p>I am passing the credentials to the SMTPClient, because I want to run my password decryption on the password before the SMTPClient uses this.</p>

<p>The issue that I'm encountering here is - when I run this once, the password is stored somehwere as "decrypted" somehow in the cache. When I try and run this method a second time in the same session, I get an error, because it's trying to decrypt a password that was already decrypte the first time it was ran. Any ideas?</p>

<pre><code>    public static void SendEmail(MailMessage mailMessage)
    {
        SmtpClient smtpClient = new SmtpClient();
        NetworkCredential nc = new NetworkCredential();
        nc = (NetworkCredential)smtpClient.Credentials;
        nc.Password = Tools.Decrypt(nc.Password);
        smtpClient.Credentials = nc;
        smtpClient.Send(mailMessage);
        nc = null;
        smtpClient.Credentials = null;
     }
</code></pre>
