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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM SDK - Execute Multiple Response Failure

(0) ShareShare
ReportReport
Posted on by

Hi,

Flow of email activity creation, attachment creation, and activity close:

  • Create email activity
  • Create email attachments while referencing above email id
  • Close email activity

Problem:

  • We are trying to use the ExecuteMultipleResponse request to create the email attachments, and it's saying that the created email id does not exist.

Question:

  • Have you experienced a similar problem with ExecuteMultipleResponse?

Code:

                emailActivityId = service.Create(emailActivity);

                //create attachments
                if (attachments != null)
                {
                    ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
                    {
                        Settings = new ExecuteMultipleSettings()
                        {
                            ContinueOnError = false,
                            ReturnResponses = true
                        },
                        // Create an empty organization request collection.
                        Requests = new OrganizationRequestCollection()
                    };

                    foreach (Entity attachment in attachments)
                    {
                        attachment["objectid"] = new EntityReference("email", emailActivityId);
                        attachment["objecttypecode"] = "email";
                        //CreateRequest createRequest = new CreateRequest { Target = attachment };
                        //requestWithResults.Requests.Add(createRequest);
                        try
                        {
                            service.Create(attachment);
                        }
                        catch(Exception ex)
                        {
                            ErrorHandler.SendErrorMessage(typeof(PublicFunctions).Name, MethodBase.GetCurrentMethod().Name, $"Failure to CREATE ActivityMimeAttachment entity", ex);
                        }
                    }

                    //ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)service.Execute(requestWithResults);

                    //foreach (var responseItem in responseWithResults.Responses)
                    //{
                    //    if (responseItem.Fault != null)
                    //    {
                    //        ErrorHandler.SendErrorMessage(typeof(PublicFunctions).Name, MethodBase.GetCurrentMethod().Name, $"Failure to CREATE ActivityMimeAttachment entity", new Exception(responseItem.Fault.Message));
                    //    }
                    //}
                }

                //close activity
                var setEmailStateReq = new SetStateRequest
                {
                    EntityMoniker = new EntityReference("email", emailActivityId),
                    State = new OptionSetValue(1),
                    Status = new OptionSetValue(2) //Completed
                };
                service.Execute(setEmailStateReq);


Thank you for taking your time to respond!

*This post is locked for comments

I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans