Esempio n. 1
0
        /// <summary>
        /// Sends the email messages geneated for this email template
        /// <param name="async">If true email messages are sent asynchronously</param>
        /// </summary>
        public void Send(bool async)
        {
            MailMessage[] messages = null;
            try
            {
                messages = this.GenerateMailMessages();
            }
            catch (Exception ex)
            {
                Logger.Error("Error generating email messages for template '" + this.Name + "' having subject '" + this.Subject + "'.", ex);
            }

            if (messages != null && messages.Length > 0)
            {
                if (async)
                {
                    SendEmailsDelegate del = new SendEmailsDelegate(AsycnSendEmails);
                    AsyncCallback      cb  = new AsyncCallback(AsyncSendEmailsCallback);
                    IAsyncResult       ar  = del.BeginInvoke(Token.Instance.StoreId, Token.Instance.UserId, messages, cb, null);
                }
                else
                {
                    SendEmails(messages);
                }
            }
        }
Esempio n. 2
0
        private static void AsyncSendEmailsCallback(IAsyncResult ar)
        {
            SendEmailsDelegate del = (SendEmailsDelegate)((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate;

            try
            {
                del.EndInvoke(ar);
            }
            catch (Exception ex)
            {
                Logger.Write("Error", Logger.LogMessageType.Error, ex);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Sends the email messages generated for this merge template
 /// <param name="recipients">Recipients for the message</param>
 /// <param name="async">If true email messages are sent asynchronously</param>
 /// </summary>
 public void Send(MailMergeRecipientCollection recipients, bool async)
 {
     if (recipients != null && recipients.Count > 0)
     {
         if (async)
         {
             SendEmailsDelegate del = new SendEmailsDelegate(AsycnSendEmails);
             AsyncCallback      cb  = new AsyncCallback(AsyncSendEmailsCallback);
             IAsyncResult       ar  = del.BeginInvoke(Token.Instance.StoreId, Token.Instance.UserId, recipients, cb, null);
         }
         else
         {
             SendEmails(recipients);
         }
     }
 }