string TitleText = "hi";
string MessageText = "hello";
// Отправляем почту
var fromEmailString = project.Variables["fromEmail"].Value;
var toEmailString = project.Variables["toEmail"].Value;
var login = project.Variables["login"].Value;
var password = project.Variables["password"].Value;
var server = project.Variables["server"].Value;
int port;
int.TryParse(project.Variables["port"].Value, out port);
bool encryptConnection;
bool.TryParse(project.Variables["encryptedConnection"].Value, out encryptConnection);
var fromAddress = new System.Net.Mail.MailAddress(fromEmailString, "moro");
var toAddress = new System.Net.Mail.MailAddress(toEmailString, toEmailString);
// create connecting to the server
var smtp = new System.Net.Mail.SmtpClient {
Host = server,
Port = port,
EnableSsl = encryptConnection,
DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential(login, password)
};
// create a message
var message = new System.Net.Mail.MailMessage(fromAddress, toAddress) {
Subject = TitleText,
Body = MessageText,
IsBodyHtml = false,
};
smtp.Send(message);
message.Dispose();