Hi,
Flow of email activity creation, attachment creation, and activity close:
Problem:
Question:
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156