コード例 #1
0
        public SendCompleteArgs(string tagName, EmailPackageData data,
                                bool isSuccess = true,
                                Exception ex   = null)
        {
            this.TagName = tagName;

            this.Data = data;

            this.IsSuccess = isSuccess;

            this.Ex = ex;

            var type = ex.GetType();

            if (type == typeof(ArgumentNullException))
            {
                ErrorCode = ARGERRORCODE;
            }
            else if (type == typeof(ObjectDisposedException))
            {
                ErrorCode = DISERRORCODE;
            }
            else if (type == typeof(InvalidOperationException))
            {
                ErrorCode = INVALIERRORDCODE;
            }
            else if (type == typeof(SmtpException))
            {
                ErrorCode = SMTPERRORCODE;
            }
            else if (type == typeof(FormatException))
            {
                ErrorCode = FORMARTERRORCODE;
            }
        }
コード例 #2
0
        public bool Send(EmailPackageData data)
        {
            try
            {
                Connect();

                var mailMessage = data.GetProviderData();

                _smtpClient.Send(mailMessage);

                OnSendComplete?.Invoke(this, new SendCompleteArgs(this.TagName, data));

                return(true);
            }
            catch (Exception ex)
            {
                OnSendComplete?.Invoke(this, new SendCompleteArgs(this.TagName, data, false, ex));

                return(false);
            }
            finally
            {
                this.CloseConnect();
            }
        }
コード例 #3
0
ファイル: EmailDispatch.cs プロジェクト: hessli/Able.Store
 public void Send(EmailPackageData data)
 {
     foreach (var item in EmailSenders)
     {
         var isSuccess = item.Send(data);
         if (isSuccess)
         {
             break;
         }
     }
 }
コード例 #4
0
 public void Send(EmailPackageData data)
 {
     _dispatch.Send(data);
 }
コード例 #5
0
 public async void SendAsync(EmailPackageData data)
 {
     await Task.Run(() => {
         _dispatch.Send(data);
     });
 }