C# · 12月 24, 2021

插入一个链接到电子邮件发送使用c#

我开发一个使用c#自动发送电子邮件的程序,我想插入到该电子邮件的网站的链接.我该怎么做? public bool genarateEmail(String from,String to,String cc,String displayName,String password,String subjet,String body) { bool EmailIsSent = false; MailMessage m = new MailMessage(); SmtpClient sc = new SmtpClient(); try { m.From = new MailAddress(from,displayName); m.To.Add(new MailAddress(to,displayName)); m.CC.Add(new MailAddress(“xxx@gmail.com”,”Display name CC”)); m.Subject = subjet; m.IsBodyHtml = true; m.Body = body; sc.Host = “smtp.gmail.com”; sc.Port = 587; sc.Credentials = new System.Net.NetworkCredential(from,password); sc.EnableSsl = true; sc.Send(m); EmailIsSent = true; } catch (Exception ex) { EmailIsSent = false; } return EmailIsSent; }

我想通过此邮件发送链接.我该怎么把它添加到电子邮件?

解决方法 String body = “Your message : <a href=’http://www.example.com’></a>” m.Body = body;