Reputation: 31
Upvotes: 2
Views: 2623
Reputation: 17562
This is a 2011 version which should be largely backwards compatible and covers the major points.
http://woodsworkblog.wordpress.com/2012/07/28/exporting-annotation-note-attachment/
public void ExportDocuments(IOrganizationService service, String filePath)
{
String fetch = @"<fetch mapping='logical' count='100' version='1.0'>
<entity name='annotation'>
<attribute name='filename' />
<attribute name='documentbody' />
<attribute name='mimetype' />
</entity>
</fetch>";
foreach (Entity e in service.RetrieveMultiple(new FetchExpression(fetch)))
{
if (!String.IsNullOrWhiteSpace(e.Attributes["documentbody"].ToString()))
{
byte[] data = Convert.FromBase64String(e.Attributes["documentbody"].ToString());
File.WriteAllBytes(filePath + e.Attributes["filename"].ToString(), data);
}
}
}
Upvotes: 0
Reputation: 15128
Annotation
entity, documentbody
field, data encoded as Base64 string.Upvotes: 1