WPF 应用程序在发送电子邮件时停止工作并出现 CLR20r3 错误
WPF application stop working with CLR20r3 error when sending email
我有使用 .NET 3.5 开发的 WPF 应用程序。
我尝试在 Windows Vista PC 上 运行 应用程序。
应用程序正常 运行ning 直到它需要发送电子邮件的部分,然后应用程序停止并出现以下错误:
Description:
Stopped working
Problem Signature:
Problem Event Name: CLR20r3
Problem Signature 01: yesmonitor.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 54c730d7
Problem Signature 04: mscorlib
Problem Signature 05: 2.0.0.0
Problem Signature 06: 53a124a5
Problem Signature 07: f50
Problem Signature 08: 7
Problem Signature 09: N3CTRYE2KN3C34SGL4ZQYRBFTE4M13NB
OS Varsion: 6.0.6002.2.2.0.768.2
Local ID: 1037
我还在 PC 上安装了 .NET 3.5 框架:
Visual C++ Redistributable 2013
Visual C++ Redistributable 2012
Visual C++ Redistributable 2008
Visual C++ Redistributable 2005
我的发送邮件代码是:
MailAddress From = new MailAddress("mymail", strIsTestPass + " - " + errorType);
MailMessage mail = new MailMessage();
mail.From = From;
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = true;
mail.To.Add("mymail");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential basicCredential = new NetworkCredential("mail", "password");
smtp.Credentials = basicCredential;
smtp.EnableSsl = true;
smtp.Send(mail);
顺便说一下它在 Win7 OS PC 上的工作方式。
可能是什么问题,我该如何解决?
将您的代码放入 try catch 并将您的 google 帐户设置 "Access for less secure apps" 设为开启。
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("example@gmail.com");
mail.To.Add("example@gmail.com);
mail.Subject = "email subject";
mail.Body = "Email body here";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("mail", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
catch (Exception)
{
throw;
}
我有使用 .NET 3.5 开发的 WPF 应用程序。 我尝试在 Windows Vista PC 上 运行 应用程序。 应用程序正常 运行ning 直到它需要发送电子邮件的部分,然后应用程序停止并出现以下错误:
Description:
Stopped working
Problem Signature:
Problem Event Name: CLR20r3
Problem Signature 01: yesmonitor.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 54c730d7
Problem Signature 04: mscorlib
Problem Signature 05: 2.0.0.0
Problem Signature 06: 53a124a5
Problem Signature 07: f50
Problem Signature 08: 7
Problem Signature 09: N3CTRYE2KN3C34SGL4ZQYRBFTE4M13NB
OS Varsion: 6.0.6002.2.2.0.768.2
Local ID: 1037
我还在 PC 上安装了 .NET 3.5 框架:
Visual C++ Redistributable 2013
Visual C++ Redistributable 2012
Visual C++ Redistributable 2008
Visual C++ Redistributable 2005
我的发送邮件代码是:
MailAddress From = new MailAddress("mymail", strIsTestPass + " - " + errorType);
MailMessage mail = new MailMessage();
mail.From = From;
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = true;
mail.To.Add("mymail");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential basicCredential = new NetworkCredential("mail", "password");
smtp.Credentials = basicCredential;
smtp.EnableSsl = true;
smtp.Send(mail);
顺便说一下它在 Win7 OS PC 上的工作方式。 可能是什么问题,我该如何解决?
将您的代码放入 try catch 并将您的 google 帐户设置 "Access for less secure apps" 设为开启。
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("example@gmail.com");
mail.To.Add("example@gmail.com);
mail.Subject = "email subject";
mail.Body = "Email body here";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("mail", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
catch (Exception)
{
throw;
}