/// <summary>
        /// Gets a list of rules and associated actions from the given store
        /// Currently only working for rules defined on from addresses, will add support for other rules soon
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static List<ParsedRule> GetRules(Store s, string storeName)
        {
            Rules rules = s.GetRules();
            List<ParsedRule> rulesList = new List<ParsedRule>();

            foreach (Rule r in rules)
            {
                if (r.Enabled)
                {
                    ParsedRule mr = new ParsedRule();

                    ParseFromAddresses(r, mr);
                    ParseToAddresses(r, mr);
                    ParseLabelMove(r, mr, storeName);
                    ParseLabelCopy(r, mr, storeName);
                    ParseSubject(r, mr);
                    ParseBody(r, mr);
                    ParseBodyOrSubject(r, mr);
                    ParseMoveToTrash(r, mr);
                    ParseDeletePermamently(r, mr);
                    ParseCC(r, mr);
                    ParseToOrCC(r, mr);
                    ParseWordsInSenderAddressses(r, mr);
                    ParseWordsInRecipientAddressses(r, mr);

                    rulesList.Add(mr);
                }
            }

            return rulesList;
        }
 private static void ParseWordsInSenderAddressses(Rule r, ParsedRule mr)
 {
     if (r.Conditions.SenderAddress.Enabled &&
             r.Conditions.SenderAddress.Address.Length > 0)
     {
         mr.SenderAddressContains = string.Join(" OR ", r.Conditions.SenderAddress.Address);
     }
 }
 private static void ParseToOrCC(Rule r, ParsedRule mr)
 {
     if (r.Conditions.ToOrCc.Enabled)
     {
         mr.MeDirectlyOrInCC = true;
     }
 }
        private static void ParseSubject(Rule r, ParsedRule mr)
        {
            if (r.Conditions.Subject.Enabled)
            {
                string[] temp = r.Conditions.Subject.Text;

                for (int i = 0; i < temp.Length; i++)
                {
                    mr.SubjectContains += temp[i];

                    if (i != temp.Length - 1)
                        mr.SubjectContains += " OR ";
                }
            }
        }
        private static void ParseToAddresses(Rule r, ParsedRule mr)
        {
            if (r.Conditions.SentTo.Recipients.Count > 0)
            {
                for (int i = 1; i <= r.Conditions.SentTo.Recipients.Count; i++)
                {
                    string temp = "";
                    // voodo to extract email addresses
                    try
                    {
                        OlAddressEntryUserType addressType = r.Conditions.SentTo.Recipients[i].AddressEntry.AddressEntryUserType;

                        if ((addressType == OlAddressEntryUserType.olExchangeRemoteUserAddressEntry) || (addressType == OlAddressEntryUserType.olExchangeUserAddressEntry))
                        {
                            temp = r.Conditions.SentTo.Recipients[i].AddressEntry.GetExchangeUser().PrimarySmtpAddress;
                        }
                        else
                        {
                            if (addressType == OlAddressEntryUserType.olSmtpAddressEntry)
                            {
                                temp = r.Conditions.SentTo.Recipients[i].AddressEntry.Address;
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        Console.WriteLine(ex);
                    }

                    // compose the address string if there are mutlitple addresses in the sentTo
                    if (!String.IsNullOrEmpty(temp))
                    {
                        if (i == 1)
                        {
                            mr.ToAddress += temp;
                        }
                        else
                        {
                            mr.ToAddress += "," + temp;
                        }
                    }
                }
            }
        }
 private static void ParseMoveToTrash(Rule r, ParsedRule mr)
 {
     try
     {
         if (r.Actions.Delete.Enabled)
         {
             mr.MoveToTrash = true;
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 private static void ParseLabelMove(Rule r, ParsedRule mr, string storeName)
 {
     try
     {
         if (r.Actions[1].ActionType == OlRuleActionType.olRuleActionMoveToFolder)
         {
             if (r.Actions.MoveToFolder.Enabled)
             {
                 MAPIFolder folder = r.Actions.MoveToFolder.Folder;
                 if (folder != null)
                 {
                     mr.MoveToFolder = CleanRuleActions(folder.FolderPath, storeName);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 private static void ParseLabelCopy(Rule r, ParsedRule mr, string storeName)
 {
     try
     {
         if (r.Actions.CopyToFolder.Enabled)
         {
             MAPIFolder folder = r.Actions.CopyToFolder.Folder;
             if (folder != null)
             {
                 mr.CopyToFolder = CleanRuleActions(folder.FolderPath, storeName);
             }
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 private static void ParseDeletePermamently(Rule r, ParsedRule mr)
 {
     try
     {
         if (r.Actions.DeletePermanently.Enabled)
         {
             mr.DeletePermanently = true;
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 private static void ParseCC(Rule r, ParsedRule mr)
 {
     if (r.Conditions.CC.Enabled)
     {
         mr.MeInCC = true;
     }
 }