public void TestGetAttachment()
        {
            string soqlQuery = "SELECT  Name, Body, ContentType from Attachment" +
                               " where OwnerId = '0050b0000032fxTAAQ'";

            Salesforce.SalesforceProxy.sObject[]  objects = sf.Query(soqlQuery);
            Salesforce.SalesforceProxy.Attachment att     = (Salesforce.SalesforceProxy.Attachment)objects[0];
            byte[] body = att.Body;
            Console.WriteLine(att.Name);
        }
        public void TestQueryAttachments()
        {
            Salesforce.SalesforceProxy.sObject[] objects = sf.Query("SELECT Name, Description, Id, ParentId, OwnerId FROM Attachment");

            for (int i = 0; i < objects.Length; i++)
            {
                Salesforce.SalesforceProxy.Attachment att = (Salesforce.SalesforceProxy.Attachment)objects[i];
                Console.WriteLine("{0}\t{1}\nDescription:\t{2}\nId:\t{3}\nParentId:\t{4}\nOwnerId:{5}\n", i + 1, att.Name, att.Description, att.Id, att.ParentId, att.OwnerId);
            }
        }
        // same as before, but set the Salesforce Files Settings: "Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments"
        public void TestCreateAttachmentAsFile() // "00P0b00000tZyBQEA0"
        {
            Salesforce.SalesforceProxy.Attachment att = new Salesforce.SalesforceProxy.Attachment()
            {
                Body        = Encoding.UTF8.GetBytes("abcde"),
                Description = "API-uploaded attachment as file",
                Name        = "TestAttAsFileFromCode",
                OwnerId     = "0050b0000032fxTAAQ", // User ID - Mihaela Armanasu
                ParentId    = "00Q0b00001XoqUnEAJ"  // Lead ID - LeadFN LeadLN
            };

            Salesforce.SalesforceProxy.SaveResult result = sf.Create(att);
        }
        public void TestCreateAttachment() // "00P0b00000tZuVoEAK" "00P0b00000taQUWEA2"
        {
            Salesforce.SalesforceProxy.Attachment att = new Salesforce.SalesforceProxy.Attachment()
            {
                Body        = Encoding.UTF8.GetBytes("abcdefg"),
                Description = "API-created attachment with Lead parent and Automated Process Owner",
                Name        = "TestFromCodeTake3",
                OwnerId     = "0050b000005EV47AAG", //Automated Process	//"0050b0000032fxTAAQ", // User ID - Mihaela Armanasu
                ParentId    = "00Q0b00001XoqW5EAJ", //LeadFN1 LeadLN1	00Q0b00001XoqW5EAJ//LeadFN LeadLN contact from converted lead 0030b000025RD4tAAG //"00Q0b00001XoqUnEAJ", // Lead ID - LeadFN LeadLN
                IsPrivate   = false,
                ContentType = "Text"
            };

            Salesforce.SalesforceProxy.SaveResult result = sf.Create(att);
        }
        public void TestRetrieveAttachmentById()
        {
            string fields = "Name, Id, ContentType, CreatedById, CreatedDate, IsDeleted, IsPrivate, OwnerId, ParentId";

            string[] ids = { "00P0b00000tZuVoEAK" };
            Salesforce.SalesforceProxy.sObject[] objects = sf.Retrieve(fields, "Attachment", ids);

            for (int i = 0; i < objects.Length; i++)
            {
                Salesforce.SalesforceProxy.Attachment att = (Salesforce.SalesforceProxy.Attachment)objects[i];
                Console.WriteLine("{0}\nName:\t{1}\nId:\t{2}\nContentType:\t{3}\nCreated:\t{4}\nCreatedBy:\t{5}\nIsDeleted:\t{6}\nIsPrivate:\t{7}" +
                                  "\nOwner:\t{8}\nParent:\t{9}",
                                  i + 1, att.Name, att.Id,
                                  att.ContentType, att.CreatedById, att.CreatedDate, att.IsDeleted, att.IsPrivate,
                                  att.OwnerId, att.ParentId);
            }
        }