Exemplo n.º 1
0
        /// <summary>
        /// Run an emailing task right now, regardless of the scheduled time of the task.
        /// </summary>
        /// <param name="task">The emailing task to run.</param>
        /// <returns>Returns the number of emails successfully sent.</returns>
        public int RunWithDefaultSender(MEmailTask task)
        {
            // modify the task sender
            task.Sender = Sender;

            return Run(task);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run an emailing task right now, regardless of the scheduled time of the task.
        /// </summary>
        /// <param name="task">The emailing task to run.</param>
        /// <returns>Returns the number of emails successfully sent.</returns>
        public int Run(MEmailTask task)
        {
            // initialize the integer value which counts the number of emails sent
            int sendCount = 0;

            // get the essential details out of the task
            MEmailClient sender = task.Sender;
            List<MEmailClient> recipients = task.Recipients;
            MEmailMessage message = task.Message;

            // send the message from the sender to each recipient
            foreach(MEmailClient recipient in recipients) {
                // send the message to the recipient
                bool isSuccess = Send(sender, recipient, message);

                // increment the send count if the message is sent to the recipient successfully
                if(isSuccess)
                    sendCount++;
            }

            // return the feedback of how many emails are completed successfully
            return sendCount;
        }