{"id":874,"date":"2012-12-10T06:06:30","date_gmt":"2012-12-10T06:06:30","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=874"},"modified":"2012-12-10T06:06:30","modified_gmt":"2012-12-10T06:06:30","slug":"create-and-attach-text-file-to-notes-in-microsoft-crm-2011","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=874","title":{"rendered":"Create and attach text file to notes in Microsoft CRM 2011"},"content":{"rendered":"<p>If you have requirement to create and attach file to notes in Ms CRM 2011 using code then this post is for you, you can use below code<\/p>\n<p>string strMessage=\u201dthis is a demo\u201d;<br \/>\nbyte[] filename = Encoding.ASCII.GetBytes(strMessage);<br \/>\nstring encodedData = System.Convert.ToBase64String(filename);<br \/>\nEntity Annotation = new Entity(&#8220;annotation&#8221;);<br \/>\nAnnotation.Attributes[&#8220;objectid&#8221;] = new EntityReference(&#8220;EntityName&#8221;,GUID);<br \/>\nAnnotation.Attributes[&#8220;objecttypecode&#8221;] = &#8220;EntityNAME&#8221;;<br \/>\nAnnotation.Attributes[&#8220;subject&#8221;] = &#8220;Demo&#8221;;<br \/>\nAnnotation.Attributes[&#8220;documentbody&#8221;] = encodedData;<br \/>\nAnnotation.Attributes[&#8220;mimetype&#8221;] = @&#8221;text\/plain&#8221;;<br \/>\nAnnotation.Attributes[&#8220;notetext&#8221;] = &#8220;Sample attachment.&#8221;;<br \/>\nAnnotation.Attributes[&#8220;filename&#8221;] = \u201cDemo.txt&#8221;;<br \/>\nService.Create(Annotation);<\/p>\n<p>Enjoy !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have requirement to create and attach file to notes in Ms CRM 2011 using code then this post is for you, you can use below code string strMessage=\u201dthis is a demo\u201d; byte[] filename = Encoding.ASCII.GetBytes(strMessage); string encodedData = System.Convert.ToBase64String(filename); Entity Annotation = new Entity(&#8220;annotation&#8221;); Annotation.Attributes[&#8220;objectid&#8221;] = new EntityReference(&#8220;EntityName&#8221;,GUID); Annotation.Attributes[&#8220;objecttypecode&#8221;] = &#8220;EntityNAME&#8221;; Annotation.Attributes[&#8220;subject&#8221;] = &#8220;Demo&#8221;; Annotation.Attributes[&#8220;documentbody&#8221;] = encodedData; Annotation.Attributes[&#8220;mimetype&#8221;]&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=874\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[32,112],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/874"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=874"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/874\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}