You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
1.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace Sevomin.Models.Helpers
{
public class SevominEmailer
{
public Dictionary<string, string> Parameters { get; set; }
public SevominEmailer()
{
}
public async void Send(string to, string subject, string template, bool isHtml)
{
SmtpClient client = new SmtpClient();
MailMessage msg = new MailMessage();
foreach (var address in to.Split(','))
msg.To.Add(address);
msg.From = new MailAddress("[email protected]", "سومین - مرکز کاریابی کنترل پروژه");
msg.SubjectEncoding = Encoding.UTF8;
msg.BodyEncoding = Encoding.UTF8;
msg.Subject = subject;
msg.IsBodyHtml = isHtml;
Func<string> getBody = () =>
{
foreach (var param in Parameters)
template = template.Replace(param.Key, param.Value);
return template;
};
msg.Body = getBody();
client.SendAsync(msg, null);
}
}
}