Press "Enter" to skip to content

Crm Dynamics 365 Get Email Attachment

Bilal Marzouk 0

Here you will find how to get the attachment of email in crm dynamics 365 .
first the relation between email and attachemnt is many to many and there is a table in crm for this relation so what we need to do:
first to get the attachment id
second to recover the attachment
third to decode the attachment binary because it is encoded in crm dynamics 365 as base64
and here is a guid how to use Crm webapi to get the attachment:



Then we could exctract our crm dynamics 365 attachemnt info
if (attachments.List.Count > 0)
{
foreach (var attachment in attachments.List)
{

var attachmentbodyBinary = attachment.FirstOrDefault(p => p.Key == “body_binary”).Value as string;
var attachmentbodytype = (attachment.FirstOrDefault(p => p.Key == “mimetype”).Value as string).Split(‘/’).Last();
var attachmentid = (attachment.FirstOrDefault(p => p.Key == “_attachmentid_value”).Value as string);

}




Leave a Reply

Your email address will not be published. Required fields are marked *