top of page

CRM How to get (download) an attachment

If you want to get an attachment from a note, then you have to get it using HTTP call. The following function returns an array of bytes that can be saved into a stream or you can convert it to Base64String (System.Convert.ToBase64String(myBytes)) if you want to save it again in CRM.

private byte GetAnnotationAttachment(Guid annotationId) { Guid attachid = annotationId; int objecttypecode = 5; //Annotation attachment OTC string url = _serverUrl + “Activities/Attachment/download.aspx?AttachmentType=” + objecttypecode.ToString() + “&AttachmentId=”+ attachid.ToString(); System.Net.WebClient myWebClient = new System.Net.WebClient(); myWebClient.Credentials =System.Net.CredentialCache.DefaultNetworkCredentials; return myWebClient.DownloadData(url); }

0 views0 comments

Recent Posts

See All
bottom of page