Make annotation attachments avalible for download on custom web page RRS feed

  • Question


    Anyone knows how to make annotation attachments available for download on custom web page? The attachments are saved in the MS CRM database as strings. I like to have a button on my custom web page (.aspx C#) that when clicked the user downloads the file.

    Thursday, March 31, 2011 8:45 AM


All replies

  • Thursday, March 31, 2011 9:28 AM
  • You can call below link on your custom web page button click to make the file as downloaded one. (pass attachmentid and attachmentType)


    Refer this link for more details.

    Thursday, March 31, 2011 9:30 AM

    Alternate is you can also download code

    Lines from SDK:

    #region How to download attachment from annotation record 
        // SDK: annotationId = new Guid("{bee08735-09d3-de11-9d71-00155da4c706}");
        Guid annotationId = setupAnnotationId;
        // Define the columns to retrieve from the annotation record.
        ColumnSet cols1 = new ColumnSet();
        cols1.Attributes = new string[] { "filename", "documentbody" };
        // Retrieve the annotation record.
        annotation annotationAttachment = (annotation)service.Retrieve(EntityName.annotation.ToString(), annotationId, cols1);
        // Download the attachment in the current execution folder.
        using (FileStream fileStream = new FileStream(annotationAttachment.filename, FileMode.OpenOrCreate))
         byte[] fileContent = new UTF8Encoding(true).GetBytes(annotationAttachment.documentbody);
         fileStream.Write(fileContent, 0, fileContent.Length);



    //NOTE: AttachmentType represents the type of the attachment: 1001 for ActivityMimeAttachment, 5 for Annotation and 1070 for SalesLiteratureItem.

    //This is the ID of the attachement that you are trying to download

    string myAttachementId = "";

    string url = "http://localhost/Activities/Attachment/download.aspx?AttachmentType=5&AttachmentId=" + myAttachementId;

    WebClient myWebClient = new WebClient();

    myWebClient.Credentials = CredentialCache.DefaultCredentials;


    Thursday, March 31, 2011 9:39 AM
  • This method does not seem the work anymore in RTM without passing the CRMWRPCToken and CRMWRPCTokenTimeStamp values.
    Thursday, March 31, 2011 10:35 AM