I have the following code in an ASP.NET site
using (MailMessage mailMessage = new MailMessage())
{
...
}
throws System.Security.Cryptography.CryptographicException: The handle is invalid. exception.
The SMTP setting in my web.config file is:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="myaccount@gmail.com">
<network host="smtp.gmail.com" defaultCredentials="false" enableSsl="true" port="587" userName="myaccount@gmail.com" password="mypass" />
</smtp>
</mailSettings>
This was working yesterday. The exception started to thrown today – after I upgraded to VS 2012.
Anyone has seen this before?
As found in a similar question
What I did to ‘fix’ is just to restart my computer and everything starts to working again.