示例#1
0
        public void Send(string sendTo, string subject, string body, IEnumerable<Attachment> attachments)
        {
            Config config = new Config();

            EmailMessage email = new EmailMessage
            {
                FromName = config.FromName,
                FromEmail = config.FromEmail,
                Subject = subject,
                SentTo = sendTo,
                Message = body,
                Type = Type.Outward,
                EventDateUTC = DateTime.UtcNow,
                Status = Status.Unknown
            };

            SmtpHost host = new SmtpHost
            {
                Address = config.SmtpHost,
                Port = config.SmtpPort,
                EnableSSL = config.EnableSsl,
                DeliveryMethod = config.DeliveryMethod,
                PickupDirectory = config.PickupDirectory
            };

            ICredentials credentials = new SmtpCredentials
            {
                Username = config.SmtpUsername,
                Password = config.SmtpUserPassword
            };

            this.Send(email, host, credentials, attachments);
        }
示例#2
0
        public async Task<bool> Send(string sendTo, string subject, string body, bool deleteAttachmentes,
            params string[] attachments)
        {
            Config config = new Config(this.Catalog);

            if (!config.Enabled)
            {
                return false;
            }


            EmailMessage email = new EmailMessage
            {
                FromName = config.FromName,
                FromEmail = config.FromEmail,
                Subject = subject,
                SentTo = sendTo,
                Message = body,
                Type = Type.Outward,
                EventDateUTC = DateTime.UtcNow,
                Status = Status.Unknown
            };

            SmtpHost host = new SmtpHost
            {
                Address = config.SmtpHost,
                Port = config.SmtpPort,
                EnableSSL = config.EnableSsl,
                DeliveryMethod = config.DeliveryMethod,
                PickupDirectory = config.PickupDirectory
            };

            ICredentials credentials = new SmtpCredentials
            {
                Username = config.SmtpUsername,
                Password = config.SmtpUserPassword
            };

            return await this.Send(email, host, credentials, deleteAttachmentes, attachments);
        }