In Dynamics CRM 4.0, file attachment to entities is pretty simple as compared to CRM 3.0. UploadFromBase64DataAnnotationRequest and UploadFromBase64DataAnnotationResponse object are both deprecated. Instead a new attribute has been introduces in annotation object with documentbody that accepts string in base64 encoding. Please find the below sample:
Reading file data into Byte array and then converting it to base64. Since I am using in memory object of StringBuilder class so I have just used str.ToString() to return string.
Byte[] data;
ASCIIEncoding encode = new ASCIIEncoding();
data = encode.GetBytes(str.ToString());
string b64 = Convert.ToBase64String(data);
Next, simply create the annotation entity and set the attributes as below:
annotation note = new annotation();
note.subject = “Test Export”;
note.filename = “exported.txt”;
note.mimetype = “text/html”;
note.documentbody = b64;
note.objectid = new Lookup();
note.objectid.type = “new_export”;
note.objectid.Value = entityid;
note.objecttypecode = new EntityNameReference();
note.objecttypecode.Value = “new_export”;
Guid annotationId = service.Create(note);
Filed under: CRM Development, MSCRM General | Tagged: Annotation, Attachment, CRM, CRM 4, Note

Hi, I want to create CRM workflow which updates the case follow up date based on priority. I
f priority is high –> follow up date would be 24 hrs (1 day) after the case create date.
If priority is normal –> follow up date would be 72 hrs (1 day) after the case create date
Now the problem is that CRM includes (or counts) the weekends (Saturday/Sundays) while calculating the days after 3 days. I want to exclude these non business days to be counted in workflow.
Is there any ways we can avoid saturdays/sundays while dynamically setting date values in CRM 4.0 workflow? Any idea??
Thanks
Regards,
Mayank
Hi
This is regarding notes entity.
Consider a scenario: I have user level access on Company and user level at notes. If another user comes and add a note into my company record.Then logically i should not be allow to update/delete that record. But i can do so.
Logically speaking it should not happen. Hence the access level permission for notes and attachement are either delete every thing or none.. kindly give me suggestion.
Hi,
Have you any example code of attaching a .PDF , .xlsx or .DOC(X) files as attachments to Email? I have got the .txt files to work but I am having difficulty getting the others to work.
Thanks,
Have you changed the mimetype. you need to be very carefull in specifying mimetype.
note.mimetype = “text/html”;
I have tried application/msword , application/pdf . For the word doc I see the text but a lot of untranslated chars as well. PDF file just says not enough data to show image. I think it must be something to do with the streamreader and encoding code ?