Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Create note with PDF Attachment using Plugin in CRM 2016

$
0
0

Hi I am trying to create note with PDF attachment using plugin.

It creating note with pdf attachment but unable to open that pdf,it says that its damaged or decoded wrongly.

Code is below-

string strMessage = "this is a demo";
byte[] byteData = Encoding.ASCII.GetBytes(strMessage);
tracingService.Trace("string in bytes " + byteData);
string encodedData = Convert.ToBase64String(byteData);
tracingService.Trace("Encoded Data " + encodedData);
Entity Annotation = new Entity("annotation");
Annotation.Attributes["subject"] = "Demo Note 7";
Annotation.Attributes["documentbody"] = encodedData;
Annotation.Attributes["mimetype"] = @"application/pdf";
Annotation.Attributes["notetext"] = "Sample attachment 7";
Annotation.Attributes["filename"] = "Demo7.pdf";
service.Create(Annotation);

If I change mimetype to @”application\msword” or @”text\plain” then its working but with PDF its showing error.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>