예제 #1
0
        public static void SendTestEmail(StmpConnection connection, string toEmail)
        {
            SmtpClient client = SetupSmtpClient(connection);

            client.Send(connection.FromEmail, toEmail, "test", "testbody");
            Console.WriteLine("Sent");
        }
예제 #2
0
        private static SmtpClient SetupSmtpClient(StmpConnection connection)
        {
            SmtpClient client = new SmtpClient(connection.Host, connection.Port)
            {
                Credentials = new NetworkCredential(connection.FromEmail, connection.Password),
                EnableSsl   = true
            };

            return(client);
        }
예제 #3
0
        public static void SendHtmlEmail(StmpConnection connection, HtmlEmailDefinition emailDefinition)
        {
            SmtpClient client = SetupSmtpClient(connection);

            MailMessage message = new MailMessage
            {
                IsBodyHtml = true,
                From       = new MailAddress(connection.FromEmail, emailDefinition.FromEmailDisplayName),
                Subject    = emailDefinition.Subject,
                Body       = emailDefinition.BodyHtml
            };

            message.To.Add(new MailAddress(emailDefinition.ToEmail, emailDefinition.ToEmailDisplayName));

            client.Send(message);
        }