从帐户实体的活动中检索来自CRM的电子邮件

时间:2016-12-16 07:59:30

标签: c# dynamics-crm crm

这是我发送电子邮件的代码。

private void SendEmail(Guid accountToGuid)
    {
        string name = GetName(service, accountToGuid);

        #region Email
        Entity fromParty = new Entity("activityparty");
        fromParty["partyid"] = new EntityReference("systemuser", ownerId);
        Entity toParty = new Entity("activityparty");
        toParty["partyid"] = new EntityReference("account", accountToGuid);

        Entity Email = new Entity("email");
        Email.Attributes["from"] = new Entity[] { fromParty };
        Email.Attributes["to"] = new Entity[] { toParty };
        Email.Attributes["subject"] = "Hello " + name;
        Email.Attributes["description"] = "Your account has been confirmed by Admin";
        Email.Attributes["ownerid"] = new EntityReference("systemuser", ownerId);
        Guid EmailId = service.Create(Email);

        SendEmailRequest req = new SendEmailRequest();

        req.EmailId = EmailId;
        req.IssueSend = true;
        req.TrackingToken = "";

        SendEmailResponse res = (SendEmailResponse)service.Execute(req);
        #endregion
    }

可以说,我已经向帐户发送了一封电子邮件。电子邮件将显示在活动部分。如何从SDK检索它?

1 个答案:

答案 0 :(得分:1)

您需要执行以下任一操作:

(链接中的完整示例)

Retrieve - 当您已经知道记录ID时,请在您的案例中发送电子邮件ID。

RetrieveMultiple - 如果您不知道记录ID,但是您要根据其他一些标准进行搜索,例如与帐户ID相关的电子邮件。