Class MailDistributor
Provides a way for applications to distribute one or more e-mails in batches by using the Simple Mail Transfer Protocol (SMTP).
public class MailDistributor
- Inheritance
-
MailDistributor
Constructors
MailDistributor(Func<SmtpClient>, int)
Initializes a new instance of the MailDistributor class.
public MailDistributor(Func<SmtpClient> carrier, int deliverySize = 20)
Parameters
carrierFunc<SmtpClient>The function delegate that will instantiate a new mail carrier per delivery.
deliverySizeintThe maximum number of mails a
carriercan deliver at a time. Default is a size of 20.
Remarks
A delivery is determined by the deliverySize. This means, that if you are to send 100 e-mails and you have a deliverySize of 20,
these 100 e-mails will be distributed to 5 invoked instances of carrier shipping up till 20 e-mails each (depending if you have a filter or not).
Methods
SendAsync(IEnumerable<MailMessage>, Func<MailMessage, bool>)
Sends the specified sequence of mails to an SMTP server.
public Task SendAsync(IEnumerable<MailMessage> mails, Func<MailMessage, bool> filter = null)
Parameters
mailsIEnumerable<MailMessage>The e-mails to send to an SMTP server.
filterFunc<MailMessage, bool>The function delegate that defines the conditions for sending of the
mailssequence.
Returns
Remarks
The function delegate filter will only include those mails that evaluates to true.
SendOneAsync(MailMessage, Func<MailMessage, bool>)
Sends the specified mail to an SMTP server.
public Task SendOneAsync(MailMessage mail, Func<MailMessage, bool> filter = null)
Parameters
mailMailMessageThe e-mail to send to an SMTP server.
filterFunc<MailMessage, bool>The function delegate that defines the conditions for the sending of
mail.
Returns
Remarks
The function delegate filter will only include the mail if that evaluates to true.