I wrote the first program in my life in c # wpf with sending mail to outlook. Mail leaves my computer normally, and any other computer gets an error and the program crashes:

The name of the failed application: NUP.exe, version: 1.0.0.0, time stamp: 0x5b51a634
The name of the failed module: KERNELBASE.dll, version: 10.0.14393.0, time stamp: 0x57898e34
Exception code: 0xe0434352
Error offset: 0x000d96c2
Failure Process ID: 0x2b58
Runtime of failed application: 0x01d4224db09239a5
The path of the failed application: \ 172.23.100.14 \ nup \ NUP.exe
Path of the failed module: C: \ Windows \ System32 \ KERNELBASE.dll
Report ID: f33e32fa-a659-4788-afaa-59192a17143e
The full name of the failed package: The application code associated with the failed package:

The second error:

Application: NUP.exe Platform Version: v4.0.30319 Description. The process was terminated due to an unhandled exception. Exception Details: System.Net.Mail.SmtpException

Please help me understand

Code

SmtpClient smtp = new SmtpClient("smtp.myoutlook.ru", 587); using (MailMessage message = new MailMessage()) { string FromAddr = "from"; string ToAddr = "to"; bool EnableSSL = false; string Login = "login"; string Password = "pass"; Encoding encoding = System.Text.Encoding.GetEncoding("windows-1251"); message.IsBodyHtml = false; message.SubjectEncoding = encoding; message.BodyEncoding = encoding; MessageBox.Show("From address: " + FromAddr); message.From = new MailAddress(FromAddr, encoding); message.Bcc.Add(new MailAddress(ToAddr, encoding)); message.Subject = "Subject"; message.Body = "Body"; smtp.UseDefaultCredentials = false; smtp.EnableSsl = EnableSSL; MessageBox.Show("Enable SSL is: " + EnableSSL.ToString()); if (!String.IsNullOrEmpty(Login) && !String.IsNullOrEmpty(Password)) { MessageBox.Show("Login is " + Login); smtp.Credentials = new System.Net.NetworkCredential(Login, Password); } smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(message); 
  • This is System.Net.Mail.SmtpException - Stranger in the Q
  • 2
    Give the full text of the error, with the frame. Probably, you need to add logging to the application - Andrey NOP
  • Well, or catch an exception in main)) - Stranger in the Q
  • Added logging. text in log: INFO 2018-07-23 02:22:18 - The SMTP server required a secure connection, or the client has not been authenticated. Server response: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM - Jan MoXa
  • Code maybe? : D - Kamushek

2 answers 2

You have everything written in error:

The SMTP server required a secure connection, or the client was not authenticated. Server response: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

And for some reason you are not including a secure connection:

 bool EnableSSL = false; 
  • if I turn on a secure connection, then nothing is sent at all and writes the error "Remote certificate is invalid according to the results of authentication" - Jan MoXa

It was a matter of limiting the right to send mail from the sender's box.