web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Import records from email attachment in Microsoft dynamics CRM

(0) ShareShare
ReportReport
Posted on by

Hi, 

I'm a newbie to MS Dynamics and want to implement a feature which can extract the records from incoming attachment and insert them into a custom entity. 

I got a post here to create a new record if the email with attachment is received but I need that attachment to be extracted (if it is .csv) and then the rows to be inserted/updated in Dynamics for a custom entity. 

If there any built-in capabilities from where I can start? Can anybody please guide me to do this?

 

Appreciate your help in advance. 

Thanks, 

Sandip

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Abby Kong Profile Picture
    6 on at
    RE: Import records from email attachment in Microsoft dynamics CRM

    Hi Sandip,

    • For email attachment, you can use field body in entity activitymimeattachment
    • For file attachment in note, you can use field documentbody in entity annotation

    Since your file is CSV file,  it can programmatically be processed easily, first use below code to retrieve the content:

            Entity attachment = service.Retrieve("activitymimeattachment", attachmentId, new ColumnSet("body")); //include filename column if you need it
            string documentBody = DecodeBase64((string)attachment["body"]);
    
            public static string DecodeBase64(string base64EncodedData)
            {
                var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
                return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
            }


    After the retrieving of csv content, if you have any csv library, that's great. Otherwise, you can: 

    string[] lines = documentBody.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
    foreach (string line in lines)
    {
          // Implement your logic of what to do with each line
    }


    Regards,

    Abby

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at
    RE: Import records from email attachment in Microsoft dynamics CRM

    Maybe this is what you are looking for:

    blogs.msdn.microsoft.com/.../how-to-import-attachments-programmatically

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans