Ejemplo n.º 1
0
        public SendMail(SmtpServer smtpServer)
        {
            smtpClient = new SmtpClient(smtpServer.Host, smtpServer.Port)
            {
                Timeout               = 180000,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                EnableSsl             = smtpServer.Ssl,
                UseDefaultCredentials = !smtpServer.RequiresAuthentication,
                Credentials           = smtpServer.RequiresAuthentication ?
                                        new NetworkCredential(smtpServer.Username, smtpServer.Password) :
                                        CredentialCache.DefaultNetworkCredentials
            };
            smtpClient.SendCompleted += (_, e) => { EndSending((MailMessage)e.UserState, e.Error); };
            smtpClient.ForceChangeIfNeeded(smtpServer);

            SupportAsync = smtpServer.SupportAsync;
        }