示例#1
0
 private void Job_SendedMail(object sender, MailSendedMailEventArgs e)
 {
     if (_mailEventReceiver != null)
     {
         _mailEventReceiver.OnSendedMail(sender, e);
     }
 }
示例#2
0
 public virtual void OnSendedMail(object sender, MailSendedMailEventArgs e)
 {
     if (SendedMail != null)
     {
         SendedMail(sender, e);
     }
 }
示例#3
0
        public void Run()
        {
            List <Email> mailList = new List <Email>();

            mailList = _queue.Dequeue();


            if (mailList != null)
            {
                foreach (Email mail in mailList)
                {
                    //Send mail

                    try
                    {
                        //process the Sending Mail event
                        MailSendingMailEventArgs sendingArgs = new MailSendingMailEventArgs();
                        sendingArgs.Email  = mail;
                        sendingArgs.Cancel = false;
                        OnSendingMail(this, sendingArgs);

                        if (sendingArgs.Cancel == false)
                        {
                            smtp.Send(mail);
                            //process the SendedMail event
                            MailSendedMailEventArgs sendedArgs = new MailSendedMailEventArgs();
                            //sendedArgs.Email = mail
                            OnSendedMail(this, sendedArgs);
                        }
                        _queue.Delete(mail.MailId);
                    }
                    catch (SmtpFailedRecipientsException ex)
                    {
                        //added by linxu on 208-7-28
                        _queue.UpdateFailure(mail.MailId, FailureInterval, NumberOfTries, IsArchiveFailure);
                        //Send Mail Error Event
                        MailErrorEventArgs args = new MailErrorEventArgs();
                        args.ErrorType = MailErrorType.SendMail;
                        args.Exception = ex;
                        OnMailError(this, args);
                    }
                    catch (SmtpException ex)
                    {
                        //Send failed
                        _queue.UpdateFailure(mail.MailId, FailureInterval, NumberOfTries, IsArchiveFailure);
                        //Send Mail Error Event
                        MailErrorEventArgs args = new MailErrorEventArgs();
                        args.ErrorType = MailErrorType.SendMail;
                        args.Exception = ex;
                        OnMailError(this, args);
                    }
                    catch (ArgumentNullException ex)
                    {
                        //added by linxu on 208-7-28
                        _queue.UpdateFailure(mail.MailId, FailureInterval, NumberOfTries, IsArchiveFailure);
                        //Send Mail Error Event
                        MailErrorEventArgs args = new MailErrorEventArgs();
                        args.ErrorType = MailErrorType.SendMail;
                        args.Exception = ex;
                        OnMailError(this, args);
                    }
                    catch (ArgumentOutOfRangeException ex)
                    {
                        //added by linxu on 208-7-28
                        _queue.UpdateFailure(mail.MailId, FailureInterval, NumberOfTries, IsArchiveFailure);
                        //Send Mail Error Event
                        MailErrorEventArgs args = new MailErrorEventArgs();
                        args.ErrorType = MailErrorType.SendMail;
                        args.Exception = ex;
                        OnMailError(this, args);
                    }
                }
            }
        }