在 CRM 中将电子邮件 Activity 设置为完成

Set Email Activity to Complete in CRM

我在发送电子邮件后在 CRM 中创建电子邮件 activity,因此我需要一种方法来将这些活动设置为已完成。是否可以在不通过 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);

我想通了。

                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);
                }