/// <summary> /// Distribute <c>CampaignActivity</c> with <c>Email</c> activity. /// </summary> /// <param name="id"><c>CampaignActvity</c> Id</param> /// <param name="fromType">Email <c>From</c> (<see cref="FromEntityType"/>)</param> /// <param name="fromId">Email <c>From</c> Id</param> /// <param name="subject">Email Subject</param> /// <param name="body">Email Body</param> /// <param name="emailTemplateId"> /// If you want to use existing <c>template</c> set this field. /// Method throws an exception (<see cref="ExceptionThrow.IfGuidEmpty(Guid, string, string)"/>) if you set this field to <see cref="Guid.Empty"/> /// </param> /// <param name="sendEmail"> /// Set <c>true</c> if you want to send created activities. /// </param> /// <param name="propagationOwnershipOptions"></param> /// <param name="ownerTypeCode"></param> /// <param name="ownerId"></param> /// <param name="queueId"></param> /// <param name="doesPropagate">Set <c>true</c>, whether the activity is both created and executed. Otherwise set <c>false</c>.</param> /// <param name="useAsync"> /// Set <c>true</c>, whether the activity is both created and executed. Otherwise set <c>false</c>. /// This field's default value is <c>true</c>, so activity will be created and executed (exp: email wil be send) /// </param> /// <param name="validateActivity"></param> /// <returns> /// Returns created <c>BulkOperation</c> Id in <see cref="DistributeCampaignActivityResponse.BulkOperationId"/> property. /// </returns> public DistributeCampaignActivityResponse DistributeByEmail(Guid id, FromEntityType fromType, Guid fromId, string subject, string body, Guid?emailTemplateId, bool sendEmail, PropagationOwnershipOptions propagationOwnershipOptions, PrincipalType ownerTypeCode, Guid ownerId, Guid?queueId, bool doesPropagate = true, bool useAsync = true, bool validateActivity = true) { ExceptionThrow.IfGuidEmpty(fromId, "fromId"); Entity from = new Entity("activityparty"); from["partyid"] = new EntityReference(fromType.Description(), fromId); Entity entity = new Entity("email"); entity["from"] = new[] { from }; if (emailTemplateId.HasValue) { ExceptionThrow.IfGuidEmpty(emailTemplateId.Value, "templateId"); } else { ExceptionThrow.IfNullOrEmpty(subject, "subject"); ExceptionThrow.IfNullOrEmpty(body, "body"); entity["subject"] = subject; entity["description"] = body; } return(Distribute(id, entity, propagationOwnershipOptions, ownerTypeCode, ownerId, queueId, emailTemplateId, doesPropagate, useAsync, sendEmail, validateActivity)); }
/// <summary> /// Add <c>From</c>. /// </summary> /// <param name="entityType"></param> /// <param name="id"></param> /// <returns><see cref="XrmEmail"/></returns> public XrmEmail From(FromEntityType entityType, Guid id) { ExceptionThrow.IfGuidEmpty(id, "From.Id"); if (string.IsNullOrEmpty(_from.Key) && _from.Value.IsGuidEmpty()) { _from = new KeyValuePair <string, Guid>(entityType.Description(), id); } else { throw new ArgumentException("You can only add one record FROM data. Please NULL to list before add new record"); } return(this); }