With Mail .NET provided by mail

 First, add: using System.Net.Mail;

 The following code, their own specific data processing to meet your needs:

  public static bool SendMail(string subject, string body)
   {
            bool result = false;
            try
            {

                    List<string> toMailList =new List<string>(){

                    {"[email protected]"},

                    {"[email protected]"}

                    };

                    if (toMailList.Count > 0)
                    {
                        MailMessage mail = new MailMessage();
                        foreach (string address in toMailList)
                        {
                            mail.To.Add(new MailAddress(address));
                        }
                        mail.From = new MailAddress("[email protected]");
                        mail.Subject = subject;
                        mail.Body = body;
                        mail.BodyEncoding = System.Text.Encoding.UTF8;
                        mail.IsBodyHtml = false;
                        SmtpClient client = new SmtpClient();
                        client.Host = 25;
                        client.Port = Convert.ToInt32("8080");
                        client.EnableSsl = True;
                        client.Send(mail);
                        result = true;
                    }
               
            }
            catch (Exception ex)
            {
           
            }
            return result;
        }

Reproduced in: https: //www.cnblogs.com/springyangwc/archive/2011/02/22/1961274.html

Guess you like

Origin blog.csdn.net/weixin_33798152/article/details/93340821