I wrote C # .NET (2.0) (so that the old machines work) application for sending letters. On Windows 7, everything is working properly, I switched to Windows 10. I get an error: "Failure when sending an e-mail message." Yuzayu box Gmail. SMTP port: 587, server: smtp.gmail.com, SSL enabled.

What could be the problem?

  • Computer name? It may sound strange, but it is important :) - Sergey Rufanov
  • @SergeyRufanov used to be Dmitry-PC on Win7, on Win10 Dmitry-PC and stayed :) - Dmitry Shulga
  • Strange. And can you then take a look at Inner Exception, from Exception, who flies to the studio? There simply more detailed information is contained. - Sergey Rufanov
  • one
    If there is an "invalid sign in the email header." - most likely that the problem is due to the Russian language / dash in the computer name. - Sergey Rufanov
  • 2
    Honestly I do not know. It is necessary to poke around in the source code of the framework to find out the exact cause. But so many. In the 4th framework, there is no such problem. I would simply rebuild the application under .NET 4.0 - it has been supported since Windows XP (see the section "System Requirements"). I very much doubt that under "what would work on old machines" you meant a bunch of machines working with Windows 2000 / ME / 98 and other "antiquities" that you have. Especially since starting from Windows 8, by default the 2nd framework is not in the system - only the 4th. - Sergey Rufanov

2 answers 2

To diagnose, to understand what is happening, you can include the following block in the <configuration> section of the app.config file

Then you can see and understand what is happening.

  <system.diagnostics> <trace autoflush="true" /> <sources> <source name="System.Net"> <listeners> <add name="MyTraceFile" /> </listeners> </source> <source name="System.Net.Sockets"> <listeners> <add name="MyTraceFile" /> </listeners> </source> </sources> <sharedListeners> <add name="MyTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="System.Net.trace.log" /> </sharedListeners> <switches> <add name="System.Net" value="Verbose" /> <add name="System.Net.Sockets" value="Verbose" /> </switches> </system.diagnostics> 

Nuggul and solved a problem XML a code, having registered in app.config

<configuration> <system.net> <mailSettings> <smtp> <network clientDomain="name"/> </smtp> </mailSettings> </system.net> <startup> <supportedRuntime version="v2.0.50727"/> </startup> </configuration>