private void LogDocumentRouting(EmailDocument document)
        {
            using (Lists listService = new Lists())
            {
                listService.Credentials = CredentialCache.DefaultCredentials;
                listService.Url = Config["SharePointSiteUrl"] + "_vti_bin/lists.asmx";

                try
                {
                    string xml = "<Method ID='1' Cmd='New'>" +
                                    "<Field Name='ID'/>" +
                                    "<Field Name='Title'>" + document.DestinationCase + "</Field>" +
                                    "<Field Name='From'>" + document.DocumentPath + "</Field>" +
                                    "<Field Name='To'>" + document.DestinationUrl + "</Field>" +
                                    "</Method>";

                    /*Get Name attribute values (GUIDs) for list and view. */
                    System.Xml.XmlNode ndListView = listService.GetListAndView(Config["RoutingLog"].Replace("/", ""), "");
                    string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
                    string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

                    /*Create an XmlDocument object and construct a Batch element and its
                    attributes. Note that an empty ViewName parameter causes the method to use the default view. */
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
                    batchElement.SetAttribute("OnError", "Continue");
                    batchElement.SetAttribute("ListVersion", "1");
                    batchElement.SetAttribute("ViewName", "");

                    /*Specify methods for the batch post using CAML. To update or delete, 
                    specify the ID of the item, and to update or add, specify 
                    the value to place in the specified column.*/
                    batchElement.InnerXml = xml;
                    XmlNode item = listService.UpdateListItems(Config["RoutingLog"].Replace("/", ""), batchElement);
                }
                catch (Exception e)
                {
                    Logger logger = LogManager.GetCurrentClassLogger();
                    logger.Log(LogLevel.Error, "LogDocumentRouting: Exception occurred when logging a successful routing of document.  \nSource: " + document.DocumentPath + "\nTo: " + document.DestinationUrl, e);
                }

            }
        }
        private bool DeleteRoutedDocument(EmailDocument routedDocument)
        {
            bool deletedSuccessfully = false;

            using (Lists listService = new Lists())
            {
                listService.Credentials = CredentialCache.DefaultCredentials;
                listService.Url = Config["SharePointSiteUrl"] + "_vti_bin/lists.asmx";

                if (routedDocument.RoutedSuccessfully)
                {
                    try
                    {
                        string xml = "<Method ID='1' Cmd='Delete'>" +
                                        "<Field Name='ID'>" + routedDocument.DocumentId + "</Field>" +
                                        "<Field Name='FileRef'>" + routedDocument.DocumentPath + "</Field>" +
                                        "</Method>";

                        /*Get Name attribute values (GUIDs) for list and view. */
                        System.Xml.XmlNode ndListView = listService.GetListAndView(Config["SharePointLibraryName"].Replace("/", ""), "");
                        string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
                        string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

                        /*Create an XmlDocument object and construct a Batch element and its
                        attributes. Note that an empty ViewName parameter causes the method to use the default view. */
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
                        batchElement.SetAttribute("OnError", "Continue");
                        batchElement.SetAttribute("ListVersion", "1");
                        batchElement.SetAttribute("ViewName", "");

                        /*Specify methods for the batch post using CAML. To update or delete, 
                        specify the ID of the item, and to update or add, specify 
                        the value to place in the specified column.*/
                        batchElement.InnerXml = xml;
                        XmlNode item = listService.UpdateListItems(Config["SharePointLibraryName"].Replace("/", ""), batchElement);
                        deletedSuccessfully = true;
                    }
                    catch (Exception e)
                    {
                        Logger logger = LogManager.GetCurrentClassLogger();
                        logger.Log(LogLevel.Error, "DeleteRoutedDocuments: Exception occurred when deleting a routed document: " + routedDocument.DocumentPath, e);
                    }
                }
            }

            return deletedSuccessfully;
        }