public static void ProcessItem(EPActivity item)
            {
                MailSendProvider.SendMessage(item);

                if (item.MPStatus == MailStatusListAttribute.Failed)
                {
                    throw new PXException(item.Exception);
                }
            }
Exemplo n.º 2
0
        private void automaticallyProcess()
        {
            bool isanyselected = false;

            var ReceiveDictionary = new Dictionary <int, List <EPActivity> >();
            var SendDictionary    = new Dictionary <int, List <EPActivity> >();

            EPActivity currentemail = Emails.Current;

            foreach (EPActivity email in Emails.Select())
            {
                if (email != null)
                {
                    if (email.Selected == true && IsMailProccessable(email))
                    {
                        if (email.IsIncome == true)
                        {
                            if (ReceiveDictionary.ContainsKey((int)email.MailAccountID))
                            {
                                ReceiveDictionary[(int)email.MailAccountID].Add(email);
                            }
                            else
                            {
                                ReceiveDictionary.Add((int)email.MailAccountID, new List <EPActivity>());
                                ReceiveDictionary[(int)email.MailAccountID].Add(email);
                            }
                        }
                        else
                        {
                            if (SendDictionary.ContainsKey((int)email.MailAccountID))
                            {
                                SendDictionary[(int)email.MailAccountID].Add(email);
                            }
                            else
                            {
                                SendDictionary.Add((int)email.MailAccountID, new List <EPActivity>());
                                SendDictionary[(int)email.MailAccountID].Add(email);
                            }
                        }
                        isanyselected = true;
                    }
                }
            }
            if (isanyselected == false)
            {
                if (currentemail != null && IsMailProccessable(currentemail))
                {
                    if (currentemail.IsIncome == true)
                    {
                        ReceiveDictionary.Add((int)currentemail.MailAccountID, new List <EPActivity>());
                        ReceiveDictionary[(int)currentemail.MailAccountID].Add(currentemail);
                    }
                    else
                    {
                        SendDictionary.Add((int)currentemail.MailAccountID, new List <EPActivity>());
                        SendDictionary[(int)currentemail.MailAccountID].Add(currentemail);
                    }
                }
            }
            foreach (var accountmessages in ReceiveDictionary)
            {
                foreach (var message in ReceiveDictionary[accountmessages.Key])
                {
                    EMailMessageReceiver.ProcessMessage(message);
                }
            }
            foreach (var accountmessages in SendDictionary)
            {
                foreach (var message in SendDictionary[accountmessages.Key])
                {
                    MailSendProvider.SendMessage(message);
                }
            }
        }