From 45b2b4b65ab46c2fc0e8afc196170962706a16f0 Mon Sep 17 00:00:00 2001 From: axunonb Date: Sun, 25 Sep 2016 01:00:03 +0200 Subject: [PATCH] Supporting .Net 4.0 target framework included --- MailMergeLib/MailMergeSender.cs | 146 +------------------------------- 1 file changed, 1 insertion(+), 145 deletions(-) diff --git a/MailMergeLib/MailMergeSender.cs b/MailMergeLib/MailMergeSender.cs index 06280bd..4fb130f 100644 --- a/MailMergeLib/MailMergeSender.cs +++ b/MailMergeLib/MailMergeSender.cs @@ -13,154 +13,10 @@ namespace MailMergeLib { - public interface IMailMergeSender - { - /// - /// Returns true, while a Send method is pending. - /// Entering a Send method while IsBusy will raise an InvalidOperationException. - /// - bool IsBusy { get; } - - /// - /// The settings for a MailMergeSender. - /// - SenderConfig Config { get; set; } - - /// - /// Sends mail messages asynchronously to all recipients supplied in the data source - /// of the mail merge message. - /// - /// Mail merge message. - /// IEnumerable data source with values for the placeholders of the MailMergeMessage. - /// IEnumerable<T> where T can be the following types: - /// Dictionary<string,object>, ExpandoObject, DataRow, class instances or anonymous types. - /// The named placeholders can be the name of a Property, Field, or a parameterless method. - /// They can also be chained together by using "dot-notation". - /// - /// - /// In order to use a DataTable as a dataSource, use System.Data.DataSetExtensions and convert it with DataTable.AsEnumerable() - /// - /// - /// If the SMTP transaction is the cause, SmtpFailedRecipientsException, SmtpFailedRecipientException or SmtpException can be expected. - /// These exceptions throw after re-trying to send after failures (i.e. after MaxFailures * RetryDelayTime). - /// - /// A send operation is pending. - /// - /// The first exception found in one of the async tasks. - Task SendAsync(MailMergeMessage mailMergeMessage, IEnumerable dataSource); - - /// - /// Sends a single mail message asyncronously. - /// - /// The method raises events before and after sending, as well as on send failure. - /// Mail merge message. - /// The following types are accepted: - /// Dictionary<string,object>, ExpandoObject, DataRow, class instances or anonymous types. - /// The named placeholders can be the name of a Property, Field, or a parameterless method. - /// They can also be chained together by using "dot-notation". - /// - /// - /// If the SMTP transaction is the cause, SmtpFailedRecipientsException, SmtpFailedRecipientException or SmtpException can be expected. - /// These exceptions throw after re-trying to send after failures (i.e. after MaxFailures * RetryDelayTime). - /// - /// A send operation is pending. - /// - Task SendAsync(MailMergeMessage mailMergeMessage, object dataItem); - - /// - /// Sends mail messages syncronously to all recipients supplied in the data source - /// of the mail merge message. - /// - /// Mail merge message. - /// IEnumerable data source with values for the placeholders of the MailMergeMessage. - /// IEnumerable<T> where T can be the following types: - /// Dictionary<string,object>, ExpandoObject, DataRow, class instances or anonymous types. - /// The named placeholders can be the name of a Property, Field, or a parameterless method. - /// They can also be chained together by using "dot-notation". - /// - /// - /// In order to use a DataTable as a dataSource, use System.Data.DataSetExtensions and convert it with DataTable.AsEnumerable() - /// - /// - /// If the SMTP transaction is the cause, SmtpFailedRecipientsException, SmtpFailedRecipientException or SmtpException can be expected. - /// These exceptions throw after re-trying to send after failures (i.e. after MaxFailures * RetryDelayTime). - /// - /// A send operation is pending. - /// - /// - /// - void Send(MailMergeMessage mailMergeMessage, IEnumerable dataSource); - - /// - /// Sends a single mail merge message. - /// - /// Message to send. - /// The following types are accepted: - /// Dictionary<string,object>, ExpandoObject, DataRow, class instances or anonymous types. - /// The named placeholders can be the name of a Property, Field, or a parameterless method. - /// They can also be chained together by using "dot-notation". - /// - /// - /// If the SMTP transaction is the cause, SmtpFailedRecipientsException, SmtpFailedRecipientException or SmtpException can be expected. - /// These exceptions throw after re-trying to send after failures (i.e. after MaxFailures * RetryDelayTime). - /// - /// A send operation is pending. - /// - /// - /// - void Send(MailMergeMessage mailMergeMessage, object dataItem); - - /// - /// Event raising before sending a mail message. - /// - event EventHandler OnMessageFailure; - - /// - /// Event raising before sending a mail message. - /// - event EventHandler OnBeforeSend; - - /// - /// Event raising after sending a mail message. - /// - event EventHandler OnAfterSend; - - /// - /// Event raising, if an error occurs when sending a mail message. - /// - event EventHandler OnSendFailure; - - /// - /// Event raising before starting with mail merge. - /// - event EventHandler OnMergeBegin; - - /// - /// Event raising during mail merge progress, i.e. after each message sent. - /// - event EventHandler OnMergeProgress; - - /// - /// Event raising after completing mail merge. - /// - event EventHandler OnMergeComplete; - - /// - /// Cancel any transactions sending or merging mail. - /// - /// The number of milliseconds to wait before cancelation. - void SendCancel(int waitTime = 0); - - /// - /// Releases all resources used by MailMergeSender - /// - void Dispose(); - } - /// /// Sends MailMergeMessages to an SMTP server. It uses MailKit.Net.Smtp.SmtpClient for low level operations. /// - public class MailMergeSender : IDisposable, IMailMergeSender + public class MailMergeSender : IDisposable { private bool _disposed; private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();