smtp exception Failure sending mail?

前端 未结 5 508
灰色年华
灰色年华 2021-01-05 01:03
StringBuilder emailMessage = new StringBuilder();
emailMessage.Append(\"Dear Payment Team ,\");
emailMessage.Append(\"

Please find the Payment ins
5条回答
  •  伪装坚强ぢ
    2021-01-05 01:28

    First, you don't need to manually read the values in your .config file. You can set the in the System.Net section and your SmtpClient object will read them automatically:

    
        
          
            
          
        
      
    

    Then, from your code, you just write:

            SmtpClient smtp = new SmtpClient();
            MailMessage mailMessage = new MailMessage();
            mailMessage.To.Add(new MailAddress("recipient@somedomain.com", "Recipient Display Name"));
            mailMessage.Subject = "Some Subject";
            mailMessage.Body = "One gorgeous body";
            smtp.Send(mailMessage);
    

    Coming back to your error, it would appear you have some kind of a network problem.

提交回复
热议问题