Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用NLog发送邮件_C#_Email_Nlog - Fatal编程技术网

C# 使用NLog发送邮件

C# 使用NLog发送邮件,c#,email,nlog,C#,Email,Nlog,我在web配置文件中配置了SMTP服务器。这是向客户端发送邮件的默认SMTP服务器 有时,如果此默认SMTP服务器无法向任何客户端发送电子邮件,我必须通过使用不同的SMTP服务器发送电子邮件来通知管理员,这是我希望通过使用NLOG实现的 NLOG的配置是 <target name="sendMail" xsi:type="Mail" html="true" subject="Mail Sending failed"

我在web配置文件中配置了SMTP服务器。这是向客户端发送邮件的默认SMTP服务器

有时,如果此默认SMTP服务器无法向任何客户端发送电子邮件,我必须通过使用不同的SMTP服务器发送电子邮件来通知管理员,这是我希望通过使用NLOG实现的

NLOG的配置是

    <target name="sendMail" xsi:type="Mail" html="true" 
                      subject="Mail Sending failed" 
                      body="${message}" 
                      to="mymail@gmail.com" 
                      from="noreply@domain.com"
                      encoding="UTF-8"
                      enableSsl="False"
                      smtpUsername="smtpUser@domain.com"
                      smtpPassword="$mySecurePass12#$"
                      smtpServer="smtp.xxxxxxxx.com"
                      smtpPort="xxx"/>
     </targets>
我通过添加 useSystemNetMailSettings=False SMT验证=基本

在nLog配置文件中

<logger name="SMTPServerChecker.SMTPCheck" minlevel="Info" writeTo="sendMail" />
catch (SmtpException ex)
            {

                NLog.LogManager.GetCurrentClassLogger().Error(ex);
            }