コード例 #1
0
        public EmailData Send(EmailData email)
        {
            if (email == null)
            {
                return new EmailData {Result = "Email class is NULL."};
            }

            try
            {
                var message = new MailMessage(new MailAddress("*****@*****.**", "Binary Calendar"),
                                              new MailAddress(email.Addresser, email.Addresser))
                    {
                        Subject = email.Subject,
                        Body = email.Body
                    };

                var smtp = new SmtpClient
                    {
                        Credentials = new NetworkCredential("*****@*****.**", "dfygbc360"),
                        Host = "smtp.gmail.com",
                        Port = 587,
                        EnableSsl = true
                    };
                smtp.Send(message);
            }
            catch (Exception exception)
            {
                email.Result = exception.Message;
            }

            return email;
        }
コード例 #2
0
ファイル: EmailSender.cs プロジェクト: rnofenko/Calendar
        private async void sendAync(EmailData email)
        {
            var task = Task<EmailData>.Factory.StartNew(() => _provider.Send(email));
            await task;

            if (task.Result.Result != null)
            {
                Logger.Error(task.Result.Result);
            }
        }