CRM 2011 Attachment Path? RRS feed

  • Question

  • Hello,

    I am using the below code to attach a .pdf file to an Opportunity. How do you specify the path of the file from where to upload??

    No matter what path I provide the note will create an attachment with a FullName which is not available.


            private static void AttachFile(Guid OpportunityId, String fullPath)
                FileInfo fileInfo = new FileInfo(fullPath);
                Annotation anno = new Annotation()
                    Subject = "Quotation",
                    FileName = fileInfo.FullName,
                    DocumentBody = Convert.ToBase64String(new UnicodeEncoding().GetBytes("Quotation")),
                    MimeType = "application/octet-stream",
                    IsDocument = true,
                    ObjectId = new Microsoft.Xrm.Sdk.EntityReference(Opportunity.EntityLogicalName, OpportunityId),
                Guid _annotationId = xrm.Create(anno);
                Console.WriteLine("Attachement Created");



    Darren Mercieca
    Monday, November 28, 2011 11:37 AM


All replies