我在发送电子邮件后在CRM中创建电子邮件活动,因此我需要一种方法将这些活动设置为已完成。是否可以在没有实际通过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);
答案 0 :(得分: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);
}