Есть ли способ интегрировать классификацию Болдона Джеймса в функцию отправки электронной почты в ядре .net (c #)?
Вот мой код для отправки электронной почты:
public string SendEmail(string subject, string body, string sender, string receiver, string filePath = null)
{
SmtpClient client = new SmtpClient(Configuration["SmtpClient"]);
client.Port = Convert.ToInt32(Configuration["SmtpPort"]); //587
client.UseDefaultCredentials = Convert.ToInt32(Configuration["UseDefaultCredential"]) == 1 ? true : false;
if (!string.IsNullOrEmpty(Configuration["SmtpUsername"]))
client.Credentials = new NetworkCredential(Configuration["SmtpUsername"].Trim(), Configuration["SmtpPassword"].Trim());
client.EnableSsl = Convert.ToInt32(Configuration["SmtpEnableSSL"]) == 1 ? true : false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(sender);
mailMessage.To.Add(receiver);
mailMessage.IsBodyHtml = true;
mailMessage.Subject = subject;
if (!string.IsNullOrEmpty(filePath))
{
mailMessage.AlternateViews.Add(getEmbeddedImage(filePath, body));
Attachment attachments = new Attachment(filePath);
//attachments.ContentDisposition.Inline = true;
mailMessage.Attachments.Add(attachments);
}
else
{
mailMessage.Body = body;
}
client.Send(mailMessage);
return "OK";
}