Exemplo n.º 1
0
        internal MailMessage ConvertEmail(EmailBuilder source)
        {
            MailMessage msg = new MailMessage();

            AddEmailAdresses(source.To, msg.To);

            msg.Subject = source.Subject;

            msg.Body = source.TextBody;

            return msg;
        }
Exemplo n.º 2
0
        private EmailBuilder BuildResponse(IReceivedEmail email)
        {
            EmailBuilder response = new EmailBuilder();
            response.To.Add(email.From);
            response.Subject = "Thank you for your email";

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Hello {0},\r\n", email.From.Name ?? email.From.Address);
            sb.AppendLine();
            sb.AppendLine("Thank you for your email.");
            sb.AppendLine();
            sb.AppendLine("This system is not yet fully operational, so please bear with us while we build support for processing your requests.");
            sb.AppendLine();
            sb.AppendLine("Thanks,");
            sb.AppendLine("Themis System.");

            response.TextBody = sb.ToString();

            return response;
        }
Exemplo n.º 3
0
        public void SendEmail(MailboxConnectionInfo mailbox, EmailBuilder message)
        {
            using (SmtpClient client = new SmtpClient())
            {
                // configure the smtp client
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Host = mailbox.SmtpHostName;
                client.Port = mailbox.SmtpPort;

                if (mailbox.SmtpRequiresAuthentication)
                {
                    client.Credentials = new System.Net.NetworkCredential(mailbox.Username, mailbox.Password);
                }

                // send the email
                MailMessage mailMessage = ConvertEmail(message);

                mailMessage.From = ConvertEmailAddress(mailbox.EmailAddress);

                client.Send(mailMessage);
            }
        }