1

I'm creating email activity in CRM after the emails have been sent out so I need a way to set those activities to completed. Is it possible to do this without actually sending the emails through CRM??

                // Create Email Activity
                Xrm.Email email = new Xrm.Email
                {
                    From = new Xrm.ActivityParty[] { fromParty },
                    Subject = subject,
                    ActivityId = Guid.NewGuid(),
                    Description = body,
                    DirectionCode = true,
                    RegardingObjectId = new EntityReference(Xrm.Account.EntityLogicalName, _acctId)
                };

                _emailId = _serviceProxy.Create(email);
4

1 回答 1

1

我想到了。

                if (_emailId != Guid.Empty)
                {
                    // Create the Request Object
                    SetStateRequest state = new SetStateRequest();

                    // Set the Request Object's Properties
                    state.State = new OptionSetValue((int)Xrm.EmailState.Completed);
                    state.Status = new OptionSetValue((int)2);

                    // Point the Request to the case whose state is being changed
                    EntityReference EntityMoniker = new EntityReference(Xrm.Email.EntityLogicalName, _emailId);
                    state.EntityMoniker = EntityMoniker;

                    // Execute the Request
                    SetStateResponse stateSet = (SetStateResponse)_serviceProxy.Execute(state);
                }
于 2015-02-23T22:33:15.377 回答