Esempio n. 1
0
        /// <summary>
        /// Queue a new email message to be sent
        /// </summary>
        /// <param name="recipient">The email address of the recipient.</param>
        /// <param name="subject">The subject of the message</param>
        /// <param name="body">The body of the message</param>
        public void QueueEmail(string recipient, string subject, string body)
        {
            EmailQueueItem emailQueueItem = new EmailQueueItem(subject, body, recipient);

            lock (this.emailMessageQueue)
            {
                this.emailMessageQueue.Enqueue(emailQueueItem);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sends a message to the email connection from the queue
        /// </summary>
        /// <param name="emailQueueItem">The email queue item to send</param>
        /// <returns>A result if the send was successful</returns>
        protected bool ProcessEmail(EmailQueueItem emailQueueItem)
        {
            try
            {
                string subject = emailQueueItem.Subject;
                string body    = emailQueueItem.Body;

                // Send the email
                lock (this.emailServerConnection)
                {
                    this.emailServerConnection.SendMessage(emailQueueItem.Recipient, emailQueueItem.Subject, emailQueueItem.Body);
                }

                this.logQueue.QueueLogEntry(new LogEntry(LogType.Info, string.Format("Email sent: {0}", subject)));
            }
            catch (Exception e)
            {
                this.logQueue.QueueLogEntry(new LogEntry(LogType.Error, string.Format("Exception in ProcessEmail - Exception: {0}", e.ToString())));
                return(false);
            }

            return(true);
        }