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; } }
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(); } }
public void Send(EmailPackageData data) { foreach (var item in EmailSenders) { var isSuccess = item.Send(data); if (isSuccess) { break; } } }
public void Send(EmailPackageData data) { _dispatch.Send(data); }
public async void SendAsync(EmailPackageData data) { await Task.Run(() => { _dispatch.Send(data); }); }