简体   繁体   English

System.Security.Cryptography.CryptographicException:句柄无效

[英]System.Security.Cryptography.CryptographicException: The handle is invalid

I am getting exception while sending mail through C# for 我通过C#发送邮件时遇到异常

SmtpClient client = new SmtpClient() 

as System.Security.Cryptography.CryptographicException: The handle is invalid. as System.Security.Cryptography.CryptographicException:句柄无效。

MailMessage mail = new MailMessage(from,to);

            mail.To.Add(to);
            mail.From = new MailAddress(from, "", System.Text.Encoding.UTF8);

            mail.Subject = "This is a test mail";

            mail.SubjectEncoding = System.Text.Encoding.UTF8;

            mail.Body = fr.message;

            mail.BodyEncoding = System.Text.Encoding.UTF8;

            mail.IsBodyHtml = true;

            mail.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient();

            //Add the Creddentials- use your own email id and password
            client.Credentials = new System.Net.NetworkCredential(from, Password);

            client.Port = 587; // Gmail works on this port

            client.Host = "smtp.gmail.com";

            client.EnableSsl = true; //Gmail works on Server Secured Layer

                client.Send(mail);

I am not getting why this happens? 我不知道为什么会这样?

Check your project settings and make sure you have checked NTLM Authentication: 检查项目设置并确保已检查NTLM身份验证:

在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TwilioRequestValidator 中的瞬态 System.Security.Cryptography.CryptographicException - Transient System.Security.Cryptography.CryptographicException in TwilioRequestValidator System.Security.Cryptography.CryptographicException:参数不正确 - System.Security.Cryptography.CryptographicException: The parameter is incorrect System.Security.Cryptography.CryptographicException:'Cryptography_OAEPDecoding' - System.Security.Cryptography.CryptographicException: 'Cryptography_OAEPDecoding' 我正在接收 System.Security.Cryptography.CryptographicException:“要解密的数据长度无效。” - I amgetting System.Security.Cryptography.CryptographicException: 'Length of the data to decrypt is invalid.' System.Security.Cryptography.CryptographicException:系统找不到指定的文件 - System.Security.Cryptography.CryptographicException: The system cannot find the file specified 如何解决System.Security.Cryptography.CryptographicException:指定了无效的提供程序类型 - How to solve System.Security.Cryptography.CryptographicException: Invalid provider type specified 重置Microsoft Identity上的密码会导致System.Security.Cryptography.CryptographicException - Resetting password on Microsoft Identity causes System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicException:密钥集不存在 - System.Security.Cryptography.CryptographicException: keyset does not exist PrivateKey抛出了System.Security.Cryptography.CryptographicException类型的异常 - PrivateKey threw an exception of type System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicException:'输入数据不是一个完整的块。' - System.Security.Cryptography.CryptographicException: 'The input data is not a complete block.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM