public bool SendMail(MailMessage message, MailerPriorityFlag priority = MailerPriorityFlag.Normal) { bool isSuccess = false; try { SmtpClient sC = new SmtpClient(_smtp); sC.Port = Convert.ToInt32(_port); sC.Credentials = new NetworkCredential(_username, _password); sC.EnableSsl = _ssl; sC.Send(message); isSuccess = true; } catch (Exception e) { } return(isSuccess); }
public bool SendMail(MailMessage message, MailerPriorityFlag priority = MailerPriorityFlag.Normal) { bool isSuccess = false; try { SmtpClient sC = new SmtpClient(_smtp); sC.Port = Convert.ToInt32(_port); sC.Credentials = new NetworkCredential(_username, _password); sC.EnableSsl = _ssl; sC.Send(message); isSuccess = true; } catch (Exception e) { } return isSuccess; }
public bool SendMail(MailerPriorityFlag priority = MailerPriorityFlag.Normal) { var provider = _factory.Create(this._smtp, this._port, this._username, this._password, this._ssl); return(provider.SendMail(_mMail, priority)); }
public void Compose(string subject, string body, List <MailerRecipient> toList, bool isBodyHtml = true, List <MailerAttachment> attachments = null, List <MailerRecipient> ccList = null, List <MailerRecipient> bccList = null, MailerPriorityFlag priority = MailerPriorityFlag.Normal) { _mMail = new MailMessage(); _mMail.Sender = new MailAddress(_senderEmailAdress); if (!string.IsNullOrEmpty(_fromEmailAddress)) { if (!string.IsNullOrEmpty(_fromDisplayName)) { _mMail.From = new MailAddress(_fromEmailAddress, _fromDisplayName); } else { _mMail.From = new MailAddress(_fromEmailAddress); } } if (!string.IsNullOrEmpty(_replyTo)) { MailAddress replyToAddress; if (!string.IsNullOrEmpty(_fromDisplayName)) { replyToAddress = new MailAddress(_replyTo, _fromDisplayName); } else { replyToAddress = new MailAddress(_replyTo); } _mMail.ReplyToList.Add(replyToAddress); } MailerRecipient.ConvertToMailAddressList(toList).ForEach(r => _mMail.To.Add(r)); if (ccList != null) { MailerRecipient.ConvertToMailAddressList(ccList).ForEach(r => _mMail.CC.Add(r)); } if (bccList != null) { MailerRecipient.ConvertToMailAddressList(bccList).ForEach(r => _mMail.Bcc.Add(r)); } switch (priority) { case MailerPriorityFlag.High: _mMail.Priority = MailPriority.High; break; case MailerPriorityFlag.Low: _mMail.Priority = MailPriority.Low; break; default: _mMail.Priority = MailPriority.Normal; break; } _mMail.Subject = subject; _mMail.Body = body; _mMail.IsBodyHtml = isBodyHtml; if (attachments != null) { MailerAttachment.ConvertToAttachmentList(attachments).ForEach(a => _mMail.Attachments.Add(a)); } }
public bool SendMail(MailerPriorityFlag priority = MailerPriorityFlag.Normal) { var provider = _factory.Create(this._smtp, this._port, this._username, this._password, this._ssl); return provider.SendMail(_mMail, priority); }
public void Compose(string subject, string body, List<MailerRecipient> toList, bool isBodyHtml = true, List<MailerAttachment> attachments = null, List<MailerRecipient> ccList = null, List<MailerRecipient> bccList = null, MailerPriorityFlag priority = MailerPriorityFlag.Normal) { _mMail = new MailMessage(); _mMail.Sender = new MailAddress(_senderEmailAdress); if (!string.IsNullOrEmpty(_fromEmailAddress)) { if (!string.IsNullOrEmpty(_fromDisplayName)) { _mMail.From = new MailAddress(_fromEmailAddress, _fromDisplayName); } else { _mMail.From = new MailAddress(_fromEmailAddress); } } if (!string.IsNullOrEmpty(_replyTo)) { MailAddress replyToAddress; if (!string.IsNullOrEmpty(_fromDisplayName)) { replyToAddress = new MailAddress(_replyTo, _fromDisplayName); } else { replyToAddress = new MailAddress(_replyTo); } _mMail.ReplyToList.Add(replyToAddress); } MailerRecipient.ConvertToMailAddressList(toList).ForEach(r => _mMail.To.Add(r)); if (ccList != null) MailerRecipient.ConvertToMailAddressList(ccList).ForEach(r => _mMail.CC.Add(r)); if (bccList != null) MailerRecipient.ConvertToMailAddressList(bccList).ForEach(r => _mMail.Bcc.Add(r)); switch (priority) { case MailerPriorityFlag.High: _mMail.Priority = MailPriority.High; break; case MailerPriorityFlag.Low: _mMail.Priority = MailPriority.Low; break; default: _mMail.Priority = MailPriority.Normal; break; } _mMail.Subject = subject; _mMail.Body = body; _mMail.IsBodyHtml = isBodyHtml; if (attachments != null) { MailerAttachment.ConvertToAttachmentList(attachments).ForEach(a => _mMail.Attachments.Add(a)); } }